How to change a link everywhere throughout one or multiple websites?

To do a recursive search and replace in a file system tree, the most effective way is to work directly on the file system. Using a tool like DreamWeaver is slow and cumbersome. Unix offers perl and find, which combined allow to do a search and replace recursively very easily. This implmentation is in perl, but sed could also be used to achieve the same result.  At the prompt (with ssh or putty) go to the root of the tree you would like to modify, and type the following commands:

for i in `find . -name .html`

do

perl -p -i~ -e 's/original text/replacement text/g' "$i"

done

The above shell script will cycle through all the subdirectories starting with the current directory and look for all .html files. “original text” can be any regular expression valid in perl.

Interested? Click here to contact us for a free consultation →