gawk [ -W gawk-options ] [ -F\^ fs ] [ -v var = val ] [ -\^- ] program-text file .\^.\^.
The command line consists of options to gawk itself, the AWK program text (if not supplied via the -f option), and values to be made available in the ARGC and ARGV pre-defined AWK variables.
Gawk accepts the following options, which should be available on any implementation of the AWK language.
-F fs Use fs for the input field separator (the value of the FS predefined variable).
-v var\^=\^val Assign the value val , to the variable var , before execution of the program begins. Such variable values are available to the BEGIN block of an AWK program.
-f " program-file" Read the AWK program source from the file program-file , instead of from the first command line argument. Multiple -f options may be used.
-\^- Signal the end of options. This is useful to allow further arguments to the AWK program itself to start with a ``-''. This is mainly for consistency with the argument parsing convention used by most other \*(PX programs.
Following the \*(PX standard, gawk -specific options are supplied via arguments to the -W option. Multiple -W options may be supplied, or multiple arguments may be supplied together if they are separated by commas, or enclosed in quotes and separated by white space. Case is ignored in arguments to the -W option.
The -W option accepts the following arguments:
\w'copyright'u+1n compat Run in compatibility mode. In compatibility mode, gawk behaves identically to \*(UX awk ; none of the GNU-specific extensions are recognized.
0 copyleft
copyright Print the short version of the GNU copyright information message on the error output.
lint Provide warnings about constructs that are dubious or non-portable to other AWK implementations.
posix This turns on compatibility mode, with the following additional restrictions:
\w'\(bu'u+1n \ex escape sequences are not recognized.
The synonym func for the keyword function is not recognized.
The operators ** and **= cannot be used in place of ^ and ^= .
version Print version information for this particular copy of gawk on the error output. This is useful mainly for knowing if the current copy of gawk on your system is up to date with respect to whatever the Free Software Foundation is distributing.
Any other options are flagged as illegal, but are otherwise ignored.
An AWK program consists of a sequence of pattern-action statements and optional function definitions.
pattern { action statements }
function name(parameter list) { statements }
Gawk first reads the program source from the program-file (s) if specified, or from the first non-option argument on the command line. The -f option may be used multiple times on the command line. Gawk will read the program text as if all the program-file s had been concatenated together. This is useful for building libraries of AWK functions, without having to include them in each new AWK