I have two files separated by tabs. Comparing files by the first field, I need to print the line where the field does not match. But the line to be printed is from the file (file1)
File1:
adu adu noun singular n/a n/a nominative
aduink adu noun plural 1pl n/a nominative
adum adu noun singular 1s n/a nominative
File2:
adu adu noun singular n/a n/a nominative
aduink adu noun plural 1pl n/a nominative
xxadum adu noun singular 1s n/a nominative
Desired output:
adum adu noun singular 1s n/a nominative
What I'm thinking:
awk 'FNR==NR{a[$1]=$0;next} !($1 in a)' file1 file2
But I need to print, the line from file (file1) not from file (file2). And I can not change the order to process files
FNR==NRexpression gets run on the first file listed after the awk script, in this casefile1. That means that your subsequent expression,!($1 in a), is evaluated against lines infile2. If you want to store$1offile2in the array and then compare lines offile1against the array, simply swap the order of the files on your awk command line.