Search And Replace 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.)

0 comments:

Post a Comment