Replacing string without opening the file

by rajesh 2009-11-10 12:38:43

We can replace the string in a file without opening it by using the string command

sed 's/old-string/new-string/g' filename


To move the string replaced output in to a new file
sed 's/cat/dog/g' filename > newfilename


So, the above code will replace cat with dog in the file named filename and save the result in newfilename.

Tagged in:

988
like
0
dislike
0
mail
flag

You must LOGIN to add comments