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.

This entry was posted in Perl and tagged . Bookmark the permalink.

NewPush has solutions to fit your business needs.  For more than a decade, our focus has been to take on the technical challenges that are the hardest and most time-consumming.  Our goal is to free up your resources to focus on the core activities of your business and to drive your business performance.  Please visit our main site at newpush.com for more information or call us at +1-303-423-4500.