AWK Built-in Variables

The following tables lists some important AWK builtin variables:

Variable Description
ARGC, ARGV command-line arguments
FILENAME name of the file that awk is currently reading.
FNR current record number in the current file, incremented on new records read
NF number of fields in the current input record
NR number of input records processed since the beginning of the program’s execution
RLENGTH length of the substring matched by the AWK’s match function
RS input record separator (default: newline)
OFS output field separator (default: blank)
ORS output record separator (default: newline)
OFMT output format for numbers (default: %.6g)
ENVIRON array of environment variables; subscripts are names.

Get hands-on with 1200+ tech skills courses.