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!

simple sed question..... 1

Status
Not open for further replies.

gringomike

Technical User
Aug 6, 2003
148
GB
Hi all,

I'm trying to use sed to permenantly change a recurring entry in a script to something else. All I need to do is change "text1" to "file2" everytime "text1" appears.

From the command line I am doing the following;

# sed 's/text1/file2/g' /path/to/script/scriptname

The script then echo's to the terminal with the changes I have made.

When I "more" the script however the changes have not taken effect.

I know I must be doing something wrong but I don't know what!

Help!

GM
 
Try something like this:
sed 's/text1/file2/g' /path/to/script/scriptname >tmp.$$ && mv tmp.$$ /path/to/script/scriptname

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Fantastic - thanks again PHV!
I thought I may have missed a switch out but this works just as I had hoped!

GM
 
Hi michelebulloni,

Do you mean sed 's/text1/r file2/g' /path/to/scriptname

If so, it replaces "text1" with the string "r file2":-(

GM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top