(gawk) Fields Summary
Info Catalog
(gawk) Variables/Fields
(gawk) Variables/Fields
(gawk) Built-in Summary
Fields
------
As each input line is read, `gawk' splits the line into FIELDS,
using the value of the `FS' variable as the field separator. If `FS'
is a single character, fields are separated by that character.
Otherwise, `FS' is expected to be a full regular expression. In the
special case that `FS' is a single space, fields are separated by runs
of spaces, tabs and/or newlines.(1) If `FS' is the null string (`""'),
then each individual character in the record becomes a separate field.
Note that the value of `IGNORECASE' ( Case-sensitivity in
Matching Case-sensitivity.) also affects how fields are split when
`FS' is a regular expression.
Each field in the input line may be referenced by its position, `$1',
`$2', and so on. `$0' is the whole line. The value of a field may be
assigned to as well. Field numbers need not be constants:
n = 5
print $n
prints the fifth field in the input line. The variable `NF' is set to
the total number of fields in the input line.
References to non-existent fields (i.e. fields after `$NF') return
the null string. However, assigning to a non-existent field (e.g.,
`$(NF+2) = 5') increases the value of `NF', creates any intervening
fields with the null string as their value, and causes the value of
`$0' to be recomputed, with the fields being separated by the value of
`OFS'. Decrementing `NF' causes the values of fields past the new
value to be lost, and the value of `$0' to be recomputed, with the
fields being separated by the value of `OFS'. Reading Input
Files Reading Files.
---------- Footnotes ----------
(1) In POSIX `awk', newline does not separate fields.
Info Catalog
(gawk) Variables/Fields
(gawk) Variables/Fields
(gawk) Built-in Summary
automatically generated byinfo2html