my input file contais this text

DOPC    1024
PW      30903
CL-     1
arg01   1

My output file should be

DOPC    1024
PW      100
CL-     10
arg01   1

I have used this following command for the single substitution and it works well.

read no_water
read length


sed s/"PW      30903"/"PW      $no_water"/ arg01.top >arg$length.top

But I want to do two substitutions by one sed command. Is it possible?
I have tried like this but it doesn't work

sed -e s/"PW      30903"/"PW      $no_water"/ ; s/"CL-     1"/"CL-     $length"/ <arg01.top >arg$length.top

Can anyone help me in this regard?

Recommended Answers

All 6 Replies

sed "s/PW      30903/PW      $no_water/;s/CL-     1/CL-     $length/" arg01.top >arg$length.top

thank you very much. It works.

Another thing, I have a file that contains this text

[ a_107081 ]
107081

I want to extract only a_107081 from this file using shell script. How do I do that. The grep and awk don't work here.

what's the pattern you're looking for ?
an a + an underline + any number of digits between square brackets?

yes, but it is within [] bracket

grep -o 'a_[[:digit:]]*' UrFile

thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.