gawkIs Splitting Records
As we’ve seen,
gawk provides three independent methods to split
input records into fields. The mechanism used is based on which of the
last assigned to. In addition, an API input parser may choose to override
the record parsing mechanism; please refer to Input Parsers for
further information about this feature.
To restore normal field splitting after using
FPAT, simply assign a value to
You can use ‘FS = FS’ to do this,
without having to know the current value of
In order to tell which kind of field splitting is in effect,
PROCINFO["FS"] (see Auto-set).
The value is
"FS" if regular field splitting is being used,
"FIELDWIDTHS" if fixed-width field splitting is being used,
"FPAT" if content-based field splitting is being used:
if (PROCINFO["FS"] == "FS") regular field splitting … else if (PROCINFO["FS"] == "FIELDWIDTHS") fixed-width field splitting … else if (PROCINFO["FS"] == "FPAT") content-based field splitting … else API input parser field splitting … (advanced feature)
This information is useful when writing a function that needs to
FIELDWIDTHS, read some records,
and then restore the original settings (see Passwd Functions for an
example of such a function).