tags:

views:

318

answers:

2

I want to print the second last column or field in awk. the number of fields is variable. I know that I should be able to use $NF but not sure how it can be used.

And this does not seem to work

awk ' { print ( $NF-- ) } '

+8  A: 
awk ' { print ( $(NF-1) ) }'
Chris Kannon
+1  A: 
awk ' { print $(NF-1) }' file
ghostdog74