Tuesday, 24 June 2008

 

Gawk Print Last Field

gawk script to print the last field of each line:

gawk -F <delimiter> "{ print $NF }".

-F defines the separator in the command line, otherwise you would prepend "BEGIN { FS=<delimiter> }".

NF is the number of fields in a line and $n is the value of the n'th field, so $NF outputs the last field.

See Also

Labels:


Comments: Post a Comment
<< Home

This page is powered by Blogger. Isn't yours?