All Questions
13
questions
0
votes
1
answer
54
views
Linux - Find string and then end of section
I have an XMLTV file. I need to get all of the programme sections for a specific channel. An example snippet:
<programme start="2023031305000 -0400" end="2023031305300 -0400&...
0
votes
1
answer
277
views
Why does this regexp — which attempts to match characters between “@” characters — fail?
I need to extract the second field of selected lines in a GEDCOM file. These lines are all of the following format:
% grep @ /tmp/XYZ | tail -5
0 @X701@ OBJE
0 @X702@ OBJE
0 @X750@ OBJE
0 @X765@ OBJE
...
1
vote
1
answer
1k
views
grep regex to include the log timestamp
I'm grepping lots of log files for certain Oracle related errors with ORA-xxxxx error codes. All the log entries start with a Timestamp(eg : 2017-11-29 23:51:46,372). Some of the log entries are multi-...
2
votes
1
answer
1k
views
Sed/awk/perl match all prefixes of a given string
I'd like to match all lines in a file that either my word is a prefix of, or the line is a prefix of my word. For example searching for "abc" should match:
a
ab
abc
abcd
abcxyz
but not:
...
0
votes
1
answer
166
views
Bash script to find content of file in a directory and add value
I have a directory with a huge number of files. I want to write a bash script to -
Enter that directory
Find out which of them are Perl scripts (but none of them have a .pl extension)
Add a line at ...
0
votes
1
answer
58
views
Save text from file between two given characters and save the output to file?
I have a file with the following kind of text:
@ heading with some text
the.actual.text.of.choice
which.can.be.several.lines
in.length.with.no.pattern
+
more.text.that.i.want.to
remove.several.lines....
-1
votes
1
answer
803
views
bash change strings with multiple escape characters
Hello i try to automate for example change one variable in php file .
root /tmp # cat defaults.inc.php|egrep "reply_all_mode"
$config['reply_all_mode'] = 0;
I try to first catch this by grep ...
3
votes
2
answers
747
views
Make perl regex search exit with failure if not found
With grep I get a failure return code/exit status if no result is found.
How can I do the same thing with perl?
Basically, I would like to change the following so that it exits with status 1 if no ...
1
vote
1
answer
2k
views
The outputs of ps and top do not match
I have a situation where I have a process, say script.pl (here it is), which seems to stick around in the output to ps auxw | grep script.pl, sometimes when load is heavy it sticks around for several ...
14
votes
2
answers
23k
views
How can I identify non-ASCII characters from the shell?
Is there a simple way to print all non-ASCII characters and the line numbers on which they occur in a file using a command line utility such as grep, awk, perl, etc?
I want to change the encoding of ...
2
votes
3
answers
752
views
SW to replace a string in Windows
I have a text file (actually XML) that I want to be able to change using a command line. In other words, as part of a Windows batch, I want to locate a string (in this case @@@@, which uses a ...
1
vote
1
answer
284
views
What does this Linux shell script line do?
I'm trying to determine exactly what the following line of shell script is doing.:
grep --files-with-matches '>' . | sort | uniq | xargs perl -pi~ -e 's/9Kp/9K /' /home/user/DATAFILE.DAT
I'm ...
2
votes
2
answers
2k
views
How to make «grep -P "foo (b.r)"» display only what's in the brackets? Do I need perl?
I have a large file, and I'm trying to get all matches of a regular expression from it.
grep -P "foo (b.r)"
Displays all the lines containing «foo b.r», and I'd like to display only what's inside of ...