Aug 9, 2018

In awk, FNR refers to the record number (typically the line number) in the current file and NR refers to the total record number.

This means that the condition NR==FNR is only true for the first file, as FNR resets back to 1 for the first line of each file but NR keeps on increasing.

$ awk '{print FILENAME, NR, FNR, $0}' file1 file2
file1 1 1 a
file1 2 2 b...