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 Customized 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 Built-in Variables That Convey Information).
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 ("CSV" in PROCINFO) CSV-based field splitting ... else 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
FPAT, read some records,
and then restore the original settings (see Reading the User Database for an
example of such a function).