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


Popular posts from this blog

Check MySQL query history from command line