Search and Replace in multiple files.

Example: Replace every instance of yourdomain with mydomain in all .html files in current path using Perl.

perl -pi -e "s/yourdomain/mydomain/g;" *.html

Same as above but make a copy of original file for backup.

perl -pi -e.bak "s/yourdomain/mydomain/g;" *.html

Or, if you prefer a lightweight solution, you can use sed:

sed -i 's/yourdomain/mydomain/g' *.html

(Add -r if you want to use extended regular expressions with sed.)

SearchAndReplaceMultipleFiles (last edited 2006-12-04 23:53:42 by DanielDeKok)