1GAWK(1) Utility Commands GAWK(1)
2
3
4
6 gawk - pattern scanning and processing language
7
9 gawk [ POSIX or GNU style options ] -f program-file [ -- ] file ...
10 gawk [ POSIX or GNU style options ] [ -- ] program-text file ...
11
13 Gawk is the GNU Project's implementation of the AWK programming lan‐
14 guage. It conforms to the definition of the language in the POSIX
15 1003.1 standard. This version in turn is based on the description in
16 The AWK Programming Language, by Aho, Kernighan, and Weinberger. Gawk
17 provides the additional features found in the current version of Brian
18 Kernighan's awk and numerous GNU-specific extensions.
19
20 The command line consists of options to gawk itself, the AWK program
21 text (if not supplied via the -f or --include options), and values to
22 be made available in the ARGC and ARGV pre-defined AWK variables.
23
24 When gawk is invoked with the --profile option, it starts gathering
25 profiling statistics from the execution of the program. Gawk runs more
26 slowly in this mode, and automatically produces an execution profile in
27 the file awkprof.out when done. See the --profile option, below.
28
29 Gawk also has an integrated debugger. An interactive debugging session
30 can be started by supplying the --debug option to the command line. In
31 this mode of execution, gawk loads the AWK source code and then prompts
32 for debugging commands. Gawk can only debug AWK program source pro‐
33 vided with the -f and --include options. The debugger is documented in
34 GAWK: Effective AWK Programming.
35
37 Gawk options may be either traditional POSIX-style one letter options,
38 or GNU-style long options. POSIX options start with a single “-”,
39 while long options start with “--”. Long options are provided for both
40 GNU-specific features and for POSIX-mandated features.
41
42 Gawk-specific options are typically used in long-option form. Argu‐
43 ments to long options are either joined with the option by an = sign,
44 with no intervening spaces, or they may be provided in the next command
45 line argument. Long options may be abbreviated, as long as the abbre‐
46 viation remains unique.
47
48 Additionally, every long option has a corresponding short option, so
49 that the option's functionality may be used from within #! executable
50 scripts.
51
53 Gawk accepts the following options. Standard options are listed first,
54 followed by options for gawk extensions, listed alphabetically by short
55 option.
56
57 -f program-file
58 --file program-file
59 Read the AWK program source from the file program-file, instead
60 of from the first command line argument. Multiple -f (or
6