Saturday, August 11, 2012

perl one liners

Social Engineering, Cooperating with Command Interpreters - Very good chapter in Programming Perl book.



To print the last field in a tab delimited text

ls -al | perl -ane 'print pop(@F), "\n"'
-- The main thing to take away here is the -an flag and the @F list.
-- different delimiter can be provided with -F flag.


or in awk.
ls -al | awk '{print $NF}'



No comments:

Post a Comment

Followers

About Me

Torrance, CA, United States