input

The awk utility can take its input from [[standard_input?]] or from files. If no input files are specified at the command line, then awk will take its input from [[standard_input?]].

Input is separated into records

In awk all input is separated into records and each record is sequentially processed according to the rules defined within the awk script. By default, each line of input is treated as a single [record] (or row of data).

Records are further divided into fields

In awk, records are further divided into fields, making them easy to manage, because processing can take place against a particular data field.

Taking input from files

The awk utility reads its input files in the order provided and performs its [[pattern_matching?]] cycle until all lines of input have been read.

Obtaining input using getline

The getline command enables awk to take input from a particular file without the need to specify the filename as a command line parameter.

Special variables related to input

The following special variables are related to input:

*Variable**Description*
FNRAn informative variable that provides the record number within the current file
FSA control variable that specifies the input field separator
NFAn informative variable that provides the number of fields within the current record
[[NR?]]An informative variable that provides the total number of records processed
RSA control variable that specifies the input record separator