[FrontPage] [TitleIndex] [WordIndex

This is a read-only archived version of wiki.centos.org

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.)

2023-09-11 07:23