Find and Replace in many files

Find and Replace in many files

This is to describe how you can find and replace a text in many many files at once. It might take some time .. but it will do the job.

The FIND and SED way

find . -type f -exec sed -i 's/OLDSTRING/NEWSTRING/g' {} \;

Example

find . -type f -exec sed -i 's/\/usr\/local\/home/\/usr\/local\/new\/home/g' {} \;
find . -type f -exec sed -i 's/Beelzebub/God/g' {} \;

Observe that paths or text with a / in them need the / to be escaped(\) for sed to accept it as a / and not end of statement.

Joomla SEF URLs by Artio