manpagez: man pages & more
info gawk
Home | html | info | man

gawk: User-modified

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