Replace string2 with string3 on all lines starting with string1
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 string2(-4.000) with string3(-2.000) on all lines starting with string1(USE solution 2, USE solution 3, …USE solution 29) but the other lines don't have to be changed.
I wrote the following script which does it, but only for the first line:
I am looking for a way to use this sed function in a loop where I could say:
If USE solution i (i=2 to 29), then do the replacement.
Being a newbie, I don't have experience at all with loops, sorry for that.
Thanks in advance.
Last edited by supernono06; 06-23-2018 at 03:59 PM..
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 such as:
---
>contig00001 length=35524 numreads=2944
gACGCCGCGCGCCGCGGCCAGGGCTGGCCCA
CAGGCCGCGCGGCGTCGGCTGGCTGAG
>contig00002 length=4242 numreads=43423
ATGCCGAAGGTCCGCCTGGGGCTGG
CGCCGGGAGCATGTAGCG
---
I would like to concatenate the lines not starting with ">"... (9 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)
e.g.
File name: File.txt
cat File.txt
Result:
#INBOUND_QUEUE=FAQ1
INBOUND_QUEUE=FAQ2
I want to get the value for one which is not commented out.
Thanks, (3 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)
I found this in the forum that searches a file for string1, substitute all occurrences of string2 with string3.
(Title: Replace string2 by string3 where string1 is found in line)
>> sed -i '/string1/s/string2/string3/g' TextFile
How will I perform the same sed command and only substitute... (3 Replies)