Invoking Summary (The GNU Awk User’s Guide)
From Get docs
Gawk/docs/latest/Invoking-Summary
Previous: Undocumented, Up: Invoking Gawk [Contents][Index]
2.11 Summary
gawkparses arguments on the command line, left to right, to determine if they should be treated as options or as non-option arguments.gawkrecognizes several options which control its operation, as described in Command-Line 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
gawkfinds 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
-eor-foptions are present,gawkexpects 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
ARGVas explained in Using ARGC and ARGV, and are processed as described in Other Command-Line Arguments. AdjustingARGCandARGVaffects howawkprocesses input. - The three standard options for all versions of
awkare-f,-F, and-v.gawksupplies 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.gawkalso lets you use the special file name/dev/stdin. gawkpays attention to a number of environment variables.AWKPATH,AWKLIBPATH, andPOSIXLY_CORRECTare the most important ones.gawk’s exit status conveys information to the program that invoked it. Use theexitstatement from within anawkprogram to set the exit status.gawkallows you to include otherawksource files into your program using the@includestatement and/or the-iand-fcommand-line options.gawkallows you to load additional functions written in C or C++ using the@loadstatement and/or the-loption. (This advanced feature is described later, in Writing Extensions forgawk.)
Previous: Undocumented, Up: Invoking Gawk [Contents][Index]