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

File: gawk.info,  Node: Invoking Summary,  Prev: Undocumented,  Up: Invoking Gawk

2.11 Summary
============

   * 'gawk' parses arguments on the command line, left to right, to
     determine if they should be treated as options or as non-option
     arguments.

   * 'gawk' recognizes several options which control its operation, as
     described in *note Options::.  All options begin with '-'.

   * Any argument that is not recognized as an option is treated as a
     non-option argument, even if it begins with '-'.

        - However, when an option itself requires an argument, and the
          option is separated from that argument on the command line by
          at least one space, the space is ignored, and the argument is
          considered to be related to the option.  Thus, in the
          invocation, 'gawk -F x', the 'x' is treated as belonging to
          the '-F' option, not as a separate non-option argument.

   * Once 'gawk' finds a non-option argument, it stops looking for
     options.  Therefore, all following arguments are also non-option
     arguments, even if they resemble recognized options.

   * If no '-e' or '-f' options are present, 'gawk' expects the program
     text to be in the first non-option argument.

   * All non-option arguments, except program text provided in the first
     non-option argument, are placed in 'ARGV' as explained in *note
     ARGC and ARGV::, and are processed as described in *note Other
     Arguments::.  Adjusting 'ARGC' and 'ARGV' affects how 'awk'
     processes input.

   * The three standard options for all versions of 'awk' are '-f',
     '-F', and '-v'.  'gawk' supplies these and many others, as well as
     corresponding GNU-style long options.

   * Nonoption command-line arguments are usually treated as file names,
     unless they have the form 'VAR=VALUE', in which case they are taken
     as variable assignments to be performed at that point in processing
     the input.

   * You can use a single minus sign ('-') to refer to standard input on
     the command line.  'gawk' also lets you use the special file name
     '/dev/stdin'.

   * 'gawk' pays attention to a number of environment variables.
     'AWKPATH', 'AWKLIBPATH', and 'POSIXLY_CORRECT' are the most
     important ones.

   * 'gawk''s exit status conveys information to the program that
     invoked it.  Use the 'exit' statement from within an 'awk' program
     to set the exit status.

   * 'gawk' allows you to include other 'awk' source files into your
     program using the '@include' statement and/or the '-i' and '-f'
     command-line options.

   * 'gawk' allows you to load additional functions written in C or C++
     using the '@load' statement and/or the '-l' option.  (This advanced
     feature is described later, in *note Dynamic Extensions::.)

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.