10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Trying to find and replace one string with another string in a file
#!/usr/bin/perl
$csd_table_path = "/file.ntab";
$find_str = '--bundle_type=021';
$repl_str = '--bundle_type=021 --target=/dev/disk1s2';
if( system("/usr/bin/perl -p -i -e 's/$find_str/$repl_str/' $csd_table_path")... (2 Replies)
Discussion started by: cillmor
2 Replies
2. Shell Programming and Scripting
I'm looking for a way to print the 4th line back from a regular expression. Kind of like the below but it has to be the 4th line before the regexp.
Print the line immediately before regexp, but not the line containing the regexp.
sed -n '/regexp/{g;1!p;};h'
here is an example of logs(i... (11 Replies)
Discussion started by: senormarquez
11 Replies
3. Shell Programming and Scripting
I'm probably just not thinking of the correct term to search for :-) But I want to match a pattern that might be 'ABC' or '1ABC' there might be three characters, or there might be four, but if there are four, the first has to be 1 (1 Reply)
Discussion started by: jnojr
1 Replies
4. Shell Programming and Scripting
I need help with a regexp to find out the ip address which can possibly be present in a URL.
The URLs can be in any of the following form
<domain>?a=12345&d=somestring1
<domain>?c=10.10.10.100&d=somestring1
<domain>?a=12345&b=somestring1&c=10.1.2.4d=somestring2... (3 Replies)
Discussion started by: ampak
3 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I'm curious about how to do a very simple thing with regular expressions that I'm unable to figure out.
If I want to find out if a string contains 'a' AND 'b' AND 'c' it can be very easily done with grep:
echo $STRING|grep a|grep b|grep c
but, how would you do that in a single... (9 Replies)
Discussion started by: jimcanoa
9 Replies
6. Shell Programming and Scripting
Hi,
I searched in the forums, but I didn't find a good solution. My problem is:
I have a string like "TEST.ABC201005.MONTHLY.D101010203".
I just want to have the string until the D100430, so that the string should look like: "TEST.ABC201005.MONTHLY.D"
The last characters after the D can be... (8 Replies)
Discussion started by: elifchen
8 Replies
7. Shell Programming and Scripting
Greetings all,
...here is yet another string of awk/sed questions from a RegExp-Challenged luser :eek:
I'm looking to have sed/awk do some clean-up on routing tables and to that end, I would like to do the following:
1.) If a line contains the word "masks" or "subnets" prepend CR/LF to... (16 Replies)
Discussion started by: SteveB-in-LV
16 Replies
8. Shell Programming and Scripting
I have successfully used regexp and sed to insert a newline before or after a line containing a matched pattern /WORD/. However, I want to insert a newline immediately following /WORD/ and not after the -line- containing the pattern matched. I can match a pattern, but it is matched via a wild card... (2 Replies)
Discussion started by: kpeirce
2 Replies
9. UNIX for Dummies Questions & Answers
Good Day,
Im new to scripting especially awk and sed. I just would like to ask help from you guys about a sed command that prints the line immediately after a regexp, but not the line containing the regexp.
sed -n '/regexp/{n;p;}' filename
What if my regexp is 3 word or a sentence. Im... (3 Replies)
Discussion started by: ownins
3 Replies
10. Shell Programming and Scripting
So I have a log that contains something like this:
What I want is to get the first occurrence of "^localhost0" (at line start) and then everything else up to the last occurrence of "^localhost0" (at line start)
Ideally I don't even care about the 2 "localhost0" lines either. All I really... (6 Replies)
Discussion started by: jjinno
6 Replies