OS Manuals

/usr/bin/gawk

GNU awk pattern-matching language

From gawk 5.4.1-r4 (os), captured 2026-11-05 by running gawk --help (exit 0). permalink

Usage: gawk [POSIX or GNU style options] -f progfile [--] file ...
Usage: gawk [POSIX or GNU style options] [--] 'program' file ...
POSIX options:		GNU long options: (standard)
	-f progfile		--file=progfile
	-F fs			--field-separator=fs
	-v var=val		--assign=var=val
Short options:		GNU long options: (extensions)
	-b			--characters-as-bytes
	-c			--traditional
	-C			--copyright
	-d[file]		--dump-variables[=file]
	-D[file]		--debug[=file]
	-e 'program-text'	--source='program-text'
	-E file			--exec=file
	-g			--gen-pot
	-h			--help
	-i includefile		--include=includefile
	-I			--trace
	-k			--csv
	-l library		--load=library
	-L[fatal|invalid|no-ext]	--lint[=fatal|invalid|no-ext]
	-M			--bignum
	-N			--use-lc-numeric
	-n			--non-decimal-data
	-o[file]		--pretty-print[=file]
	-O			--optimize
	-p[file]		--profile[=file]
	-P			--posix
	-r			--re-interval
	-s			--no-optimize
	-S			--sandbox
	-t			--lint-old
	-V			--version

To report bugs, use the `gawkbug' program.
For full instructions, see the node `Bugs' in `gawk.info'
which is section `Reporting Problems and Bugs' in the
printed version.  This same information may be found at
https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.
PLEASE do NOT try to report bugs by posting in comp.lang.awk,
or by using a web forum such as Stack Overflow.

Source code for gawk formal releases may be obtained from
https://ftp.gnu.org/gnu/gawk/.

Source code for gawk beta releases may be obtained from
https://www.skeeve.com/gawk/.

Alpha and beta releases have a version number >= 60 or that end in a letter.

gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output.

Examples:
	gawk '{ sum += $1 }; END { print sum }' file
	gawk -F: '{ print $1 }' /etc/passwd
Options (29)
OptionDescriptionSource
-f, --file progfileRead the AWK program source from the file program-file, instead of from the first command line argument.help + man
-F, --field-separator fsUse fs for the input field separator (the value of the FS predefined variable).help + man
-v, --assign var=valAssign the value val to the variable var, before execution of the program begins.help + man
-b, --characters-as-bytesTreat all input data as single-byte characters.help + man
-c, --traditionalRun in compatibility mode.help + man
-C, --copyrightPrint the short version of the GNU copyright information message on the standard output and exit successfully.help + man
-d file--dump-variables[=file]help
-D file--debug[=file]help
-e, --source 'program-text'Use program-text as AWK program source code.help + man
-E, --exec fileSimilar to -f, however, this option is the last one processed.help + man
-g, --gen-potScan and parse the AWK program, and generate a GNU .pot (Portable Object Template) format file on standard output with entries for all localizable strings in the program.help + man
-h, --helpPrint a relatively short summary of the available options on the standard output.help + man
-i, --include includefileLoad an awk source library.help + man
-I, --tracePrint the internal byte code names as they are executed when running the program.help + man
-k, --csvEnable CSV special processing.help + man
-l, --load libraryLoad a gawk extension from the shared library lib.help + man
-L fatal|invalid|no-ext--lint[=fatal|invalid|no-ext]help
-M, --bignumForce arbitrary precision arithmetic on numbers.help + man
-N, --use-lc-numericForce gawk to use the locale's decimal point character when parsing input data.help + man
-n, --non-decimal-dataRecognize octal and hexadecimal values in input data.help + man
-o file--pretty-print[=file]help
-O, --optimizeEnable gawk's default optimizations upon the internal representation of the program.help + man
-p file--profile[=file]help
-P, --posixThis turns on compatibility mode, and disables a number of common extensions.help + man
-r, --re-intervalEnable the use of interval expressions in regular expression matching.help + man
-s, --no-optimizeDisable gawk's default optimizations upon the internal representation of the program.help + man
-S, --sandboxRun gawk in sandbox mode, disabling the system() function, input redirection with getline, output redirection with print and printf, and loading dynamic extensions.help + man
-t, --lint-oldProvide warnings about constructs that are not portable to the original version of UNIX awk.help + man
-V, --versionPrint version information for this particular copy of gawk on the standard output.help + man
Examples (1) from the manual page, untested

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.