I know there are several similar questions about there, but I can't get the answers to work and I am completely flummoxed as to what i'm doing wrong.
I have a file that looks like:
 name1 na 1002
 name2 na 1002
 name3 na 1003
I want to query it with a key file that looks like:
 1002 1
 1003 2
desired output:
 name1 na 1002 1
 name2 na 1002 1
 name3 na 1003 2
However, i'm only getting the output of the first file using this code:
 awk  'FNR==NR {a[$1]=$2;next} $3 in a {print $0,a[$1]}' key file
what am I missing that it's not printing anything for the a[$1]?
 
    