samedi 8 octobre 2016

AWK if last field equals

I've done considerable searching and i'm getting frustrated. I'm trying have conditional response on the last field of a file that has dynamic number of fields. I've tried reworking the field separator, but that's been unsuccessful.

It prints the correct field when i use awk '{print $(NF)}'

I attempted to do something like this: '{ if ($(NF) ~ /LTO/); print $NF}' but all fields are returning true. I suspect that the variable substitution in the if statement is not returning the value I want it to.

I also tried setting it to a variable, but again i received all true. I'm new to AWK and would like to get it to work.

Thanks

Aucun commentaire:

Enregistrer un commentaire