Replace word in unix

April 12, 2011 at 03:43:27
Specs: Unix
I have a file in unix, in which there is a lot of occurence of word log.
I want to change it with word root.

Please tell me the command for this.

I used the command
sed 's/log/root/' filename.

but the changes are not getting reflected in original file.

See More: Replace word in unix

Report •

April 12, 2011 at 03:51:26

sed -i 's/log/root/g' filename

Report •

April 12, 2011 at 04:11:07
sed 's/log/root/' filename

with this command, I am able to change the log to root.
I want this change to get saved in the original file
What to do for this?

Report •

April 12, 2011 at 05:02:18
sed 's/log/root/g' filename > newfilename; mv newfilename filename

Click Here on HowTo ask good Question to get best Help
Let us know, if the problem is solved !!!

Report •

Related Solutions

April 12, 2011 at 05:20:34
The -i switch is quicker.

Report •

April 12, 2011 at 07:07:43
The -i switch is a GNU (i.e. Linux) innovation. It is not supported in classic unix distributions like Sun or AIX.

Report •

Ask Question