gawk: User-modified
1
1 7.5.1 Built-in Variables That Control 'awk'
1 -------------------------------------------
1
1 The following is an alphabetical list of variables that you can change
1 to control how 'awk' does certain things.
1
1 The variables that are specific to 'gawk' are marked with a pound
1 sign ('#'). These variables are 'gawk' extensions. In other 'awk'
1 implementations or if 'gawk' is in compatibility mode (⇒Options),
1 they are not special. (Any exceptions are noted in the description of
1 each variable.)
1
1 'BINMODE #'
1 On non-POSIX systems, this variable specifies use of binary mode
1 for all I/O. Numeric values of one, two, or three specify that
1 input files, output files, or all files, respectively, should use
1 binary I/O. A numeric value less than zero is treated as zero, and
1 a numeric value greater than three is treated as three.
1 Alternatively, string values of '"r"' or '"w"' specify that input
1 files and output files, respectively, should use binary I/O. A
1 string value of '"rw"' or '"wr"' indicates that all files should
1 use binary I/O. Any other string value is treated the same as
1 '"rw"', but causes 'gawk' to generate a warning message. 'BINMODE'
DONTPRINTYET 1 is described in more detail in ⇒PC Using. 'mawk' (*note1DONTPRINTYET 1 is described in more detail in ⇒PC Using. 'mawk' (⇒
Other Versions) also supports this variable, but only using
1 numeric values.
1
1 'CONVFMT'
11 A string that controls the conversion of numbers to strings (⇒
Conversion). It works by being passed, in effect, as the first
1 argument to the 'sprintf()' function (⇒String Functions).
1 Its default value is '"%.6g"'. 'CONVFMT' was introduced by the
1 POSIX standard.
1
1 'FIELDWIDTHS #'
1 A space-separated list of columns that tells 'gawk' how to split
1 input with fixed columnar boundaries. Starting in version 4.2,
1 each field width may optionally be preceded by a colon-separated
1 value specifying the number of characters to skip before the field
1 starts. Assigning a value to 'FIELDWIDTHS' overrides the use of
1 'FS' and 'FPAT' for field splitting. ⇒Constant Size for
1 more information.
1
1 'FPAT #'
1 A regular expression (as a string) that tells 'gawk' to create the
1 fields based on text that matches the regular expression.
1 Assigning a value to 'FPAT' overrides the use of 'FS' and
1 'FIELDWIDTHS' for field splitting. ⇒Splitting By Content
1 for more information.
1
1 'FS'
1 The input field separator (⇒Field Separators). The value is
1 a single-character string or a multicharacter regular expression
1 that matches the separations between fields in an input record. If
1 the value is the null string ('""'), then each character in the
1 record becomes a separate field. (This behavior is a 'gawk'
1 extension. POSIX 'awk' does not specify the behavior when 'FS' is
1 the null string. Nonetheless, some other versions of 'awk' also
1 treat '""' specially.)
1
1 The default value is '" "', a string consisting of a single space.
1 As a special exception, this value means that any sequence of
1 spaces, TABs, and/or newlines is a single separator. It also
1 causes spaces, TABs, and newlines at the beginning and end of a
1 record to be ignored.
1
1 You can set the value of 'FS' on the command line using the '-F'
1 option:
1
1 awk -F, 'PROGRAM' INPUT-FILES
1
1 If 'gawk' is using 'FIELDWIDTHS' or 'FPAT' for field splitting,
1 assigning a value to 'FS' causes 'gawk' to return to the normal,
1 'FS'-based field splitting. An easy way to do this is to simply
1 say 'FS = FS', perhaps with an explanatory comment.
1
1 'IGNORECASE #'
1 If 'IGNORECASE' is nonzero or non-null, then all string comparisons
1 and all regular expression matching are case-independent. This
1 applies to regexp matching with '~' and '!~', the 'gensub()',
1 'gsub()', 'index()', 'match()', 'patsplit()', 'split()', and
1 'sub()' functions, record termination with 'RS', and field
1 splitting with 'FS' and 'FPAT'. However, the value of 'IGNORECASE'
1 does _not_ affect array subscripting and it does not affect field
11 splitting when using a single-character field separator. ⇒
Case-sensitivity.
1
1 'LINT #'
1 When this variable is true (nonzero or non-null), 'gawk' behaves as
1 if the '--lint' command-line option is in effect (⇒Options).
1 With a value of '"fatal"', lint warnings become fatal errors. With
1 a value of '"invalid"', only warnings about things that are
1 actually invalid are issued. (This is not fully implemented yet.)
1 Any other true value prints nonfatal warnings. Assigning a false
1 value to 'LINT' turns off the lint warnings.
1
1 This variable is a 'gawk' extension. It is not special in other
1 'awk' implementations. Unlike with the other special variables,
1 changing 'LINT' does affect the production of lint warnings, even
1 if 'gawk' is in compatibility mode. Much as the '--lint' and
1 '--traditional' options independently control different aspects of
1 'gawk''s behavior, the control of lint warnings during program
1 execution is independent of the flavor of 'awk' being executed.
1
1 'OFMT'
11 A string that controls conversion of numbers to strings (⇒
Conversion) for printing with the 'print' statement. It works by
1 being passed as the first argument to the 'sprintf()' function
1 (⇒String Functions). Its default value is '"%.6g"'.
1 Earlier versions of 'awk' used 'OFMT' to specify the format for
1 converting numbers to strings in general expressions; this is now
1 done by 'CONVFMT'.
1
1 'OFS'
1 The output field separator (⇒Output Separators). It is
1 output between the fields printed by a 'print' statement. Its
1 default value is '" "', a string consisting of a single space.
1
1 'ORS'
1 The output record separator. It is output at the end of every
1 'print' statement. Its default value is '"\n"', the newline
1 character. (⇒Output Separators.)
1
1 'PREC #'
1 The working precision of arbitrary-precision floating-point
1 numbers, 53 bits by default (⇒Setting precision).
1
1 'ROUNDMODE #'
1 The rounding mode to use for arbitrary-precision arithmetic on
1 numbers, by default '"N"' ('roundTiesToEven' in the IEEE 754
1 standard; ⇒Setting the rounding mode).
1
1 'RS'
1 The input record separator. Its default value is a string
1 containing a single newline character, which means that an input
1 record consists of a single line of text. It can also be the null
1 string, in which case records are separated by runs of blank lines.
1 If it is a regexp, records are separated by matches of the regexp
1 in the input text. (⇒Records.)
1
1 The ability for 'RS' to be a regular expression is a 'gawk'
1 extension. In most other 'awk' implementations, or if 'gawk' is in
1 compatibility mode (⇒Options), just the first character of
1 'RS''s value is used.
1
1 'SUBSEP'
1 The subscript separator. It has the default value of '"\034"' and
1 is used to separate the parts of the indices of a multidimensional
1 array. Thus, the expression 'foo["A", "B"]' really accesses
1 'foo["A\034B"]' (⇒Multidimensional).
1
1 'TEXTDOMAIN #'
1 Used for internationalization of programs at the 'awk' level. It
1 sets the default text domain for specially marked string constants
1 in the source text, as well as for the 'dcgettext()',
11 'dcngettext()', and 'bindtextdomain()' functions (⇒
Internationalization). The default value of 'TEXTDOMAIN' is
1 '"messages"'.
1