awk FNR - Number of Records in File


Example

Provides the total number of records processed by the awk instance relative to the files awk is processing

cat > file1
suicidesquad
harley quinn
joker
deadshot

cat > file2
avengers
ironman
captainamerica
hulk

awk '{print FNR}' file1 file2
1
2
3
4
1
2
3
4

Each file had 4 lines each, so whenever awk encountered an EOF FNR was reset to 0.