DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(gawk.info) AWKPATH Variable

Info Catalog (gawk.info) Other Arguments (gawk.info) Invoking Gawk (gawk.info) Obsolete
 
 The `AWKPATH' Environment Variable
 ==================================
 
    The previous section described how `awk' program files can be named
 on the command line with the `-f' option.  In most `awk'
 implementations, you must supply a precise path name for each program
 file, unless the file is in the current directory.
 
    But in `gawk', if the file name supplied to the `-f' option does not
 contain a `/', then `gawk' searches a list of directories (called the
 "search path"), one by one, looking for a file with the specified name.
 
    The search path is a string consisting of directory names separated
 by colons.  `gawk' gets its search path from the `AWKPATH' environment
 variable.  If that variable does not exist, `gawk' uses a default path,
 which is `.:/usr/local/share/awk'.(1) (Programs written for use by
 system administrators should use an `AWKPATH' variable that does not
 include the current directory, `.'.)
 
    The search path feature is particularly useful for building up
 libraries of useful `awk' functions.  The library files can be placed
 in a standard directory that is in the default path, and then specified
 on the command line with a short file name.  Otherwise, the full file
 name would have to be typed for each file.
 
    By using both the `--source' and `-f' options, your command line
 `awk' programs can use facilities in `awk' library files.   A
 Library of `awk' Functions Library Functions.
 
    Path searching is not done if `gawk' is in compatibility mode.  This
 is true for both `--traditional' and `--posix'.   Command Line
 Options Options.
 
       you
 must include the current directory in the path, either by including `.'
 explicitly in the path, or by writing a null entry in the path.  (A
 null entry is indicated by starting or ending the path with a colon, or
 by placing two colons next to each other (`::').)  If the current
 directory is not included in the path, then files cannot be found in
 the current directory.  This path search mechanism is identical to the
 shell's.
 
    Starting with version 3.0, if `AWKPATH' is not defined in the
 environment, `gawk' will place its default search path into
 `ENVIRON["AWKPATH"]'. This makes it easy to determine the actual search
 path `gawk' will use.
 
    ---------- Footnotes ----------
 
    (1) Your version of `gawk' may use a different directory; it will
 depend upon how `gawk' was built and installed. The actual directory
 will be the value of `$(datadir)' generated when `gawk' was configured.
 You probably don't need to worry about this though.
 
Info Catalog (gawk.info) Other Arguments (gawk.info) Invoking Gawk (gawk.info) Obsolete
automatically generated byinfo2html