Skip to main content
  1. Blog/

AWK Built-in Variables

·186 words·1 min
unix
Lucas Melin
Author
Lucas Melin
Focused on helping developers succeed.

A common choice for manipulating and processing large text files on UNIX systems is awk. I was using awk in March of 2017 and thought it would be helpful to have a list of awk built-in variables for future reference.

NameDescription
FSThe field separator (or column separator). This defines the character that separates each column of data, such as \t for tab-separated value files. It can be assigned directly, or awk can be invoked with the file flag -F in order to parse the separator out of the file automatically.
OFSThe field separator to use when outputting. By default, the output field separator is the space character.
RSThe record separator (or row separator). This defines the character that separates each row of data, such as \n for newline-delimited files.
ORSThe output record separator. The delimiter is output between every record instance.
NRThe number of records processed (line number) across all files
FNRThe number of records processed (line number) in just the current file.
NFThe number of fields in the current record (number of columns in the current row).