Editing Files With a Perl One-Liner
If you have a group of files on which you’d like to perform a search-and-replace edit, try this handy Perl one-liner: $ perl -p -e 's/original/replacement/g' *.html This command will replace all occurences of the string “original” with the string “replacement” in all files named *.html. This command can also work with Perl’s powerful regular expression engine. If you’d like to save an unmodified copy of your files, try change the option like this: $ perl -p -i .bak -e 's/original/replacement/g' *.html This will make a copy of your original files with the .bak extension added, just in case your editing goes wrong.
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
Leave a Reply
You must be logged in to post a comment.





