NR - Number of Records in AWK in UNIX

NR is a AWK built-in variable and it denotes number of records being processed.

Usage : NR can be used in action block represents number of line being processed and if it is used in END it can print number of lines totally processed

Example : Using NR to print line number in a file using AWK

awk '{print NR, $0;}' test.txt

test.txt contents

Output of awk command
1 ray
2 shawn
3 eliza

Note : When multiple files are used, NR count is incremental. If you want to get relative count with respect to the file, use FNR instead.