To replace the 2nd string2 is easy
But this searches string1 throughout the line, then starts over and substitutes the 2nd string2 from the beginning of the line.
If you really want the 1st string2 after string1, then you have to include string1 into the substitution command.
I suggest perl and its minimum match. perl -pe works a bit like sed:
The $1 refers to what was captured in the 1st ( ) group.
The .*? is a non-greedy .* (any character any times).
Hi All,
I have a file say abc.xml. In this file, I need to search for a pattern “SAP_GATEWAY_HOST”; if this pattern found and the next line also contain the pattern “nwprc03.cos” then I need to replace this pattern “nwprc03.cos” with some other pattern “nwdrc03.apjp”.
$ cat abc.xml... (3 Replies)
Hi all,
can any one suggest me the script to grep multiple strings from ps -ef
pls correct the below script . its not working/
i want to print OK if all the below process are running in my solaris system. else i want to print NOT OK.
bash-3.00$ ps -ef | grep blu
lscpusr 48 42 ... (11 Replies)
Hi,
I have a file with the following content:
---------
a 3242 tc_5 gdfg4
random text
a 3242 tc_6 gdfg4
random text
a 3242 tc_7 gdfg4
random text
a 3242 tc_4 gdfg4
---------
I want to replace the lines containing tc_? (tc_5, tc_6 etc. even with unknown numbers) with the found... (5 Replies)
Hello All...
I have a text file (.ics) which I need to read into a variable but ONLY the part including and after 'BEGIN:VEVENT' and ending with END:VEVENT
Anything before BEGIN:VEVENT or after END:VEVENT should be ignored.
Thanks for input
Jeff
BEGIN:VCALENDAR
VERSION:2.0... (3 Replies)
How do I use awk to find the records in a file that contains two specific strings?
I have tried piping and using awk two times, but I don't know how to do it in one action. (2 Replies)
Hi All
There is another challenge which stand in front of me. And want all to have the experience with that
I have a file in Unix say a.txt. What I was trying is to read the file line by line and matching the line to particular pattern, and if that pattern found I want to replace that line... (5 Replies)
My OS is Windows 10 and I am using Cygwin.
The file 1 content is:
USE solution 2; -4.000
USE solution 3; -4.000
…
USE solution 29; -4.000
USE solution 30; -4.000
USE solution 31; -4.000
….
USE solution 89; -4.000
...
USE solution 202; -4.000
etc...
I need to replace... (8 Replies)
Hello,
My aim is to search string1 in all lines. When found, find and replace string2 by string3 if possible.
TextFile:
Here is my first line
Second line with string1 & string2
Not last line but it contains string1
Expected output:
Here is my first line
The second line with string1 &... (6 Replies)
Hello,
This is a bit complicated for me.
My scenario in MyFile:
Search string1,
When string1 is found, grep the line containing string1, go back over that line in upward direction and grep the first line containing string2.
Here is an example:
MyFile
His email address... (17 Replies)