Linux: Find and Replace in Files
by bhartsock on Jun.13, 2007, under Linux
Thanks to Jon H., I can now do find and replace in files on Linux machines from the command line. Its pretty simple, but I had never bothered to figure it out.
Here are two examples. The first is for just one file, the meat and potatoes are in the second example, which does a find and replace in all PHP files.
1 2 | sed -i -e "s/TOREPLACE/REPLACEMENT/g" temp.txt; sed -i -e "s/TOREPLACE/REPLACEMENT/g" `find -name '*.php'`; |
Super helpful.
August 6th, 2007 on 7:05 am
Hi,
Good post,
very simple and easy to use.
keep it up !