RS.
The possibilities are as follows:
Value of RS | Records are split on … | awk / gawk |
|---|---|---|
| Any single character | That character | awk |
The empty string ("") | Runs of two or more newlines | awk |
| A regexp | Text that matches the regexp | gawk |
FNR indicates how many records have been read from the current input file;
NR indicates how many records have been read in total.
gawk sets RT to the text matched by RS.
awk further splits
the records into individual fields, named $1, $2, and so
on. $0 is the whole record, and NF indicates how many
fields there are. The default way to split fields is between whitespace
characters.
$NF. Fields
may also be assigned values, which causes the value of $0 to be
recomputed using the value of OFS current at the time of
assignment to the field.
Assigning to a field with a number
greater than NF creates the field and rebuilds the record, using
OFS to separate the fields. Incrementing NF does the same
thing. Decrementing NF throws away fields and rebuilds the record.
| Field separator value | Fields are split … | awk / gawk |
|---|---|---|
| --csv used | Using CSV definitions, overrides other methods | gawk, nawk |
FS == " " | On runs of whitespace | awk |
FS == any single character | On that character | awk |
FS == regexp | On text matching the regexp | awk |
FS == "" | Such that each individual character is a separate field | gawk |
FIELDWIDTHS == list of columns | Based on character position | gawk |
FPAT == regexp | On the text surrounding text matching the regexp | gawk |
gawk and BWK awk, Comma-Separated-Value splitting
with --csv overrides all other methods of fields splitting.
For gawk, PROCINFO["CSV"] will exist if CSV-based
splitting is in effect.
FS may be set from the command line using the -F option.
This can also be done using command-line variable assignment.
PROCINFO["FS"] to see how fields are being split.
getline in its various forms to read additional records
from the default input stream, from a file, or from a pipe or coprocess.
PROCINFO[file, "READ_TIMEOUT"] to cause reads to time out
for file.
Use PROCINFO[file, "RETRY"] to have reads that fail with getline
not be fatal.
awk;
gawk ignores them if not in POSIX mode.