Go backward to User-modified.
Go up to Built-in Variables.

Built-in Variables that Convey Information
==========================================

   This is a list of the variables that are set automatically by `awk'
on certain occasions so as to provide information to your program.

`ARGC'
`ARGV'
     The command-line arguments available to `awk' programs are stored
     in an array called `ARGV'.  `ARGC' is the number of command-line
     arguments present.  See Invoking `awk': Command Line.  `ARGV' is
     indexed from zero to `ARGC - 1'.  For example:

          awk 'BEGIN {
                 for (i = 0; i < ARGC; i++)
                     print ARGV[i]
               }' inventory-shipped BBS-list

     In this example, `ARGV[0]' contains `"awk"', `ARGV[1]' contains
     `"inventory-shipped"', and `ARGV[2]' contains `"BBS-list"'.  The
     value of `ARGC' is 3, one more than the index of the last element
     in `ARGV' since the elements are numbered from zero.

     The names `ARGC' and `ARGV', as well the convention of indexing
     the array from 0 to `ARGC - 1', are derived from the C language's
     method of accessing command line arguments.

     Notice that the `awk' program is not entered in `ARGV'.  The other
     special command line options, with their arguments, are also not
     entered.  But variable assignments on the command line *are*
     treated as arguments, and do show up in the `ARGV' array.

     Your program can alter `ARGC' and the elements of `ARGV'.  Each
     time `awk' reaches the end of an input file, it uses the next
     element of `ARGV' as the name of the next input file.  By storing a
     different string there, your program can change which files are
     read.  You can use `"-"' to represent the standard input.  By
     storing additional elements and incrementing `ARGC' you can cause
     additional files to be read.

     If you decrease the value of `ARGC', that eliminates input files
     from the end of the list.  By recording the old value of `ARGC'
     elsewhere, your program can treat the eliminated arguments as
     something other than file names.

     To eliminate a file from the middle of the list, store the null
     string (`""') into `ARGV' in place of the file's name.  As a
     special feature, `awk' ignores file names that have been replaced
     with the null string.

`ARGIND'
     The index in `ARGV' of the current file being processed.  Every
     time `gawk' opens a new data file for processing, it sets `ARGIND'
     to the index in `ARGV' of the file name.  Thus, the condition
     `FILENAME == ARGV[ARGIND]' is always true.

     This variable is useful in file processing; it allows you to tell
     how far along you are in the list of data files, and to
     distinguish between multiple successive instances of the same
     filename on the command line.

     While you can change the value of `ARGIND' within your `awk'
     program, `gawk' will automatically set it to a new value when the
     next file is opened.

     This variable is a `gawk' extension; in other `awk' implementations
     it is not special.

`ENVIRON'
     This is an array that contains the values of the environment.  The
     array indices are the environment variable names; the values are
     the values of the particular environment variables.  For example,
     `ENVIRON["HOME"]' might be `/u/close'.  Changing this array does
     not affect the environment passed on to any programs that `awk'
     may spawn via redirection or the `system' function.  (In a future
     version of `gawk', it may do so.)

     Some operating systems may not have environment variables.  On
     such systems, the array `ENVIRON' is empty.

`ERRNO'
     If a system error occurs either doing a redirection for `getline',
     during a read for `getline', or during a `close' operation, then
     `ERRNO' will contain a string describing the error.

     This variable is a `gawk' extension; in other `awk' implementations
     it is not special.

`FILENAME'
     This is the name of the file that `awk' is currently reading.  If
     `awk' is reading from the standard input (in other words, there
     are no files listed on the command line), `FILENAME' is set to
     `"-"'.  `FILENAME' is changed each time a new file is read (
see Reading Input Files: Reading Files.).

`FNR'
     `FNR' is the current record number in the current file.  `FNR' is
     incremented each time a new record is read (*note Explicit Input
     with `getline': Getline.).  It is reinitialized to 0 each time a
     new input file is started.

`NF'
     `NF' is the number of fields in the current input record.  `NF' is
     set each time a new record is read, when a new field is created,
     or when `$0' changes (see Examining Fields: Fields.).

`NR'
     This is the number of input records `awk' has processed since the
     beginning of the program's execution.  (*note How Input is Split
     into Records: Records.).  `NR' is set each time a new record is
     read.

`RLENGTH'
     `RLENGTH' is the length of the substring matched by the `match'
     function (see Built-in Functions for String Manipulation: String Functions.).  `RLENGTH' is set by invoking the `match' function.
     Its value is the length of the matched string, or -1 if no match
     was found.

`RSTART'
     `RSTART' is the start-index in characters of the substring matched
     by the `match' function (*note Built-in Functions for String
     Manipulation: String Functions.).  `RSTART' is set by invoking the
     `match' function.  Its value is the position of the string where
     the matched substring starts, or 0 if no match was found.