I recently came across a command that allows me to search and replace a string of text in all files within a directory structure. This is very useful for updating static information in HTML files and the like.

find ./ -iname \*.htm\* -exec sed -i 's/www\.example\.com/www2\.example\.com/g' {} \;

Note that you must denote special characters with the backslash character (e.g., the dots in www.example.com).

 

Leave a Reply