Perl - One Liners
perldoc perlrun
How to print lines of the selected files between the START and END markers, without printing the markers themselves?
perl -ne 'print if s/^START\n$// .. s/^END\n$//' files...
How to print lines following (and including) a line that matches a pattern?
perl -ne '$i = 1 if /pattern/; print if $i--' files
How to replace Windows line terminators with Unix line terminators?
perl -i -pe 's/\r\n/\n/g' /usr/share/vim/vim63/ftplugin/pdoc4vim.vim
How to search filename for all instance of sysread and replace them with read?
perl -p -i -e 's/sysread/read/g' filename
How to execute a string of perl code from command line?
perl -e 'print "Hello World\n"'
What are the important switches?
-e: indicates that the entire program is provided right there on the command line
-n: add a loop around your -e code.
-i: cause any changes to be written back to the file when done
How to read a file (input.txt) line by line and extract out matching part of the line match the specified pattern?
perl -ne 'print "$1\n" if /Binary files my_quantros.war(.*?) and production_quantros.war\1 differ/' input.txt
page revision: 2, last edited: 11 Oct 2015 22:24