Tuesday, September 09, 2008

replace word in a file

To replace a word in a file, use

perl -pi -e 's/abc/def/;' xyz

or

sed -e 's/abc/def/;' xyz > xyz_new

To make the replacement in place, use sed -i filename. then the file will be replaced after the command.

sed -e 's/abc/def/;' -i xyz


No comments:

Post a Comment