Thursday, July 3, 2014

Print specific column of a text file

To print the second last column of a tab delimited file,

awk -F '\t' '{print $(NF-1)}' file

NF is a special awk variable that contains the number of fields in the current record.

No comments: