Friday, March 29, 2013

What is the difference between NR and FNR in AWK?

NR - The ordinal number of the current record from the start of input.
FNR - The ordinal number of the current record in the current file.

So NR counts the lines from the very beginning continuously until the end. FNR restarts the counting at the beginning of each input file.

No comments :