Wednesday, October 5, 2011

Make inplace changes with sed

If you want sed to actually make changes to a file, not just show the output on stdout, use the -i option.  If you add an extension, it will be used to create a backup of the file before changing it.

-i is inline
-i.bak (No space) will make a .bak

sed -i.bak 's/findthis/changetothis/' myfile