Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace multiple lines in a file

Status
Not open for further replies.

geffry

Programmer
Jun 26, 2002
33
US
Hi,

I have a file where there are 10 lines.
In a shell script i get some user input, Now i have to update the lines 2,4,7 (example) in that file. and update the contents of the file with these values.

I can do it by writing to a temporary file and then renaming the file. I don't want to create files and do. Is there any way to do it without creation of temp. files. I know there are way, one way i remember use vi editor inside the shell script. But i forgot how to do it,

i tried something like this,
vi $noiseparam << eoffile
:s/$ngenip/$tngenip/g
:s/$chan1/$tchan1/g
:s/$chan2/$tchan2/g
:wq
eoffile

inside the shell script, it did not work,

can you guys give a solution?

Thanks in advance
 
Code:
ex - ${noiseparam} <<EOF
%s/$ngenip/$tngenip/g
wq!
EOF



vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top