Friday, July 8, 2011

Perl one liner for In-Place editing.

Three perl single liner for In-Place editing. In all of the cases, the command replaces all occurrence of word 'target' with 'replace'.

With backup.
$ perl -pe 's/target/replace/g' < input.txt > output.txt
$ perl -i.bak -pe 's/target/replace/g' inout.txt
With out backup. 
$ perl -i -pe 's/target/replace/g' input.txt

No comments:

Post a Comment