| "what's the lane?" four options squeezed together: -l:
1. "chomps" the input (which here means: removes newlines (if present) from each line, more general explanation:
http://perldoc.perl.org/functions/chomp.html
2. and automatically adds a newline to each output newline (see below how to achieve this in a shorter way with a relatively new Perl feature). -a: turns on auto-split-mode: this splits the input (like awk) into the @F (for fields) array. The default separator is one (or many) spaces, i.e. it behaves like AWK. -n: makes Perl process the input in an implicit while loop around the input, which is processed line-wise: "as long as there is another line, process it!" -e: execute the next command line argument as a Perl program (argument in this case beeing 'print $F[0]'). Note that the example can be shortened if you use
-E instead of -e. -E enables all extensions and new features of Perl (which aren't enabled with -e because of backwards compatibility). This allows you to use 'say' instead of 'print' which adds a trailing newline automatically and lets you drop the -l option (if you don't need the 'chomp' behaviour explained above): $ perl -anE 'say $F[0]'
Of course, the AWK command line is still shorter - and that's expected, because AWK is more specialized than Perl.Still, Perl one liners are often very useful and can do other things better / shorter than AWK - especially if the one-liner uses one of the many libraries that are available for Perl. A thorough reference of all Perl command line options is available at: http://perldoc.perl.org/perlrun.html
or just: $ man perlrun
|