Monday, November 19, 2012

Perl Filters

A nice trick for easily writing Perl filters:

perl -pe 's/a/b/g'

will do the substitution on each line of input and spit it back out. And:

perl -i bak -pe 's/a/b/g' file1 file2....

will do the same, except it will change the given files and back them up to file1.bak, etc, as it does so.


No comments:

Post a Comment

Comments welcome, but they are expected to be civil.
Please don't bother spamming me. I'm only going to delete it.