Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ynonp
Last active December 16, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ynonp/5497555 to your computer and use it in GitHub Desktop.
Save ynonp/5497555 to your computer and use it in GitHub Desktop.
# Program 1 -- print the third column of each line
perl -pe '$_ =perl -ane 'print $F[2], "\n"'
# Program 2 -- treat each line as a number and sum all lines
perl -pe '$\+=$_}{'
# Program 3 -- print an empty line after each line
perl -pe '$\="\n"'
# Program 4 -- number the lines
perl -pe '$_="$.$_"'
# Program 5 -- print everything between START and END
perl -ne 'print if /START/../END/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment