/ Published in: Perl
-p tells perl to assume a simple loop around the code we give it to run.
-i.bak tells perl that we wish to create backups of the files we modify with the suffix .bak.
-e "..." tells perl that we wish to execute the code inside the quotes.
And finally the file list is the list of files that we wish to operate upon.
Escape special characters such as ".", "?", "*", or "/" by preceding them with the "\" character.
Example: change "Bob" to "Steve" on all HTML files in the current directory:
perl -pi.bak -e "s/Bob/Steve/g" *.html
-i.bak tells perl that we wish to create backups of the files we modify with the suffix .bak.
-e "..." tells perl that we wish to execute the code inside the quotes.
And finally the file list is the list of files that we wish to operate upon.
Escape special characters such as ".", "?", "*", or "/" by preceding them with the "\" character.
Example: change "Bob" to "Steve" on all HTML files in the current directory:
perl -pi.bak -e "s/Bob/Steve/g" *.html
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
perl -pi.bak -e "s/Old text/New text/g" file1 file2 file3