Published in: Perl
URL: http://perl.com/pub/a/2004/08/09/commandline.html?page=2
couple of useful snippets from an article I found at Perl.com
#print the result of search-and-replace to the terminal perl -pe 's/bart/milhouse/g' test.html #search-and-replace, with backup #leave the suffix off of -i to overwrite perl -i.bak -pe 's/bart/milhouse/g' test.html #echo the number of lines in a file perl -lne 'END { print $t } @w = /(\w+)/g; $t += @w' test.html #cat file with line numbers # -p prints $_ each iteration perl -pe '$_ = "$. = $_"' test.html
You need to login to post a comment.
