I use nawk to search for a string in a particular field and then print that particular field, however if for some reason, the string I want to print is in the next field, it will not print it.
Ex. cat file | nawk '$5 ~ /TEST/{print $5, $6}'
This works fine when TEST is in the 5th field, however if TEST appears in the 6th field, I would like to print the 6th and 7th fields.
How can I use awk to do this?
Any help would be greatly appreciated.
Thanks,
John
Ex. cat file | nawk '$5 ~ /TEST/{print $5, $6}'
This works fine when TEST is in the 5th field, however if TEST appears in the 6th field, I would like to print the 6th and 7th fields.
How can I use awk to do this?
Any help would be greatly appreciated.
Thanks,
John