Quote:
Originally Posted by
pc2001
Thanks Aia!
It would be great if you could elaborate a bit on the structure and syntax of the code!
FNR==NR : FNR and NR are built-in management variables in awk. FNR keeps a tally of the records read from the current file, NR keeps a tally of every record so far read from any files given.
If FNR is equal to NR, then we are dealing with the first file, in this case file2 and it execute the following part:
{a[$1$2]++; next} : That creates an array named
a, which index is the combination of fields 1 and 2 and then skip to next line. This will happen only with first file given as argument
{if (! a[$1$2])print} : When the program gets here, it is dealing with the second file, and if it has not seen fields 1 and 2 before, it displays it.