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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace a word

Status
Not open for further replies.

vti

Technical User
Feb 26, 2001
189
TR
hi again.
I would like to replace a specific word in a file with a new word.For example:


My file look like :

Monday
Tuesday Saturday Thursday
Friday Sunday

I want to replace Saturday with Wednesday but how ?

Thanks for any help..
 
{ gsub("Saturday", "Wednesday"); print }


vlad

NOTE: when in doubt - "man awk"
 
it works well but it's only print out on the screen ,when i edit the file again it is still wrong.How can i save the file.?

Thanks a lot
 
You could use sed instead :

sed "s/Saturday/Wednesday/g" oldfile > newfile

then rename newfile to oldfile ( having saved it of course)
DickieBird
 
thanks a lot ,both of these works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top