This could answer your question:
awk 'NR==FNR{++a[$2,$3];next} {line++;if(!(a[$2,$3])){print line}}' record1 record2
Explanation:
FNR==NR
When you have two (or more) input files to awk
, FNR will reset back to 1
on the first line of the next file whereas NR will continuing incrementing
from where it left off. By checking FNR==NR
we are essentially checking
to see if we are currently parsing the first file.
++a[$2,$3]
If we are parsing the first file (see above) then create an associative
array with the first field $2 and second field $3 as the key and post increment the value by 1.This essentially lets us create a 'seen' list.
next
This command tells awk not to process any further commands and to read in
the next record and start over. We do this because file1 is only meant to set the associative array
!(a[$2,$3])
This line only executes when FNR==NR is false, i.e. we are not parsing
file1 and thus must be parsing file2. We then use the first field $1 and second field $2 of file2 as the key to index into our 'seen' list created earlier. If the
value returned is 0 it means we didn't see it in file1 and therefore we
should print this line. Conversely, if the value is non-zero then we
did see it in file1 and thus we should not print its value.
Note that !(a[$2,$3]) is equivalent to !(a[$2,$3]){print} because the default action when one is not given is to print the entire line.