AWK: getting last column value

If you need to get value of last column in awk you can use built-in variable NF which means the number of fields in record.

awk '$(NF) !~ /-/ { print $0 }'  access_log

Or next, if you need next to the last field. And so on.

awk '$(NF-1) != /-/ { print $0 }' access_log

Leave a Reply

Your email address will not be published. Required fields are marked *