pgawk (1) Linux Manual Page
NAME
gawk – pattern scanning and processing language
SYNOPSIS
gawk [ POSIX or GNU style options ] -f program-file [ — ] file …
gawk [ POSIX or GNU style options ] [ — ] program-text file …
pgawk [ POSIX or GNU style options ] -f program-file [ — ] file …
pgawk [ POSIX or GNU style options ] [ — ] program-text file …
dgawk [ POSIX or GNU style options ] -f program-file [ — ] file …
DESCRIPTION
Gawk is the GNU Project’s implementation of the AWK programming language. It conforms to the definition of the language in the POSIX 1003.1 Standard. This version in turn is based on the description in The AWK Programming Language, by Aho, Kernighan, and Weinberger. Gawk provides the additional features found in the current version of UNIX awk and a number of GNU-specific extensions.
The command line consists of options to gawk itself, the AWK program text (if not supplied via the -f or –file options), and values to be made available in the ARGC and ARGV pre-defined AWK variables.
Pgawk is the profiling version of gawk. It is identical in every way to gawk, except that programs run more slowly, and it automatically produces an execution profile in the file awkprof.out when done. See the –profile option, below.
Dgawk is an awk debugger. Instead of running the program directly, it loads the AWK source code and then prompts for debugging commands. Unlike gawk and pgawk, dgawk only processes AWK program source provided with the -f option. The debugger is documented in GAWK: Effective AWK Programming.
OPTION FORMAT
Gawk options may be either traditional POSIX-style one letter options, or GNU-style long options. POSIX options start with a single “-”, while long options start with “–”. Long options are provided for both GNU-specific features and for POSIX-mandated features.
Gawk– specific options are typically used in long-option form. Arguments to long options are either joined with the option by an = sign, with no intervening spaces, or they may be provided in the next command line argument. Long options may be abbreviated, as long as the abbreviation remains unique.
Additionally, each long option has a corresponding short option, so that the option’s functionality may be used from within #! executable scripts.
OPTIONS
Gawk accepts the following options. Standard options are listed first, followed by options for gawk extensions, listed alphabetically by short option.
-
-fprogram-file -
–fileprogram-file Read the AWK program source from the file program-file, instead of from the first command line argument. Multiple-f(or–file) options may be used. -
-Ffs -
–field-separatorfs Use fs for the input field separator (the value of theFSpredefined variable). -
-vvar=val -
–assignvar=val Assign the value val to the variable var, before execution of the program begins. Such variable values are available to theBEGINblock of an AWK program. -
-b -
–characters-as-bytesTreat all input data as single-byte characters. In other words, don’t pay any attention to the locale information when attempting to process strings as multibyte characters. The–posixoption overrides this one. -
-c -
–traditionalRun in compatibility mode. In compatibility mode, gawk behaves identically to UNIX awk; none of the GNU-specific extensions are recognized. SeeGNU EXTENSIONS, below, for more information. -
-C -
–copyrightPrint the short version of the GNU copyright information message on the standard output and exit successfully. -
-d[file] -
–dump-variables[=file] Print a sorted list of global variables, their types and final values to file. If no file is provided, gawk uses a file namedawkvars.outin the current directory.Having a list of all the global variables is a good way to look for typographical errors in your programs. You would also use this option if you have a large program with a lot of functions, and you want to be sure that your functions don’t inadvertently use global variables that you meant to be local. (This is a particularly easy mistake to make with simple variable names like
i,j, and so on.) -
-eprogram-text -
–sourceprogram-text Use program-text as AWK program source code. This option allows the easy intermixing of library functions (used via the-fand–fileoptions) with source code entered on the command line. It is intended primarily for medium to large AWK programs used in shell scripts. -
-Efile -
–execfile Similar to-f, however, this is option is the last one processed. This should be used with#!scripts, particularly for CGI applications, to avoid passing in options or source code (!) on the command line from a URL. This option disables command-line variable assignments. -
-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. The program itself is not executed. See the GNU gettext distribution for more information on.potfiles. -
-h -
–helpPrint a relatively short summary of the available options on the standard output. (Per the GNU Coding Standards, these options cause an immediate, successful exit.) -
-L[value] -
–lint[=value] Provide warnings about constructs that are dubious or non-portable to other AWK implementations. With an optional argument offatal, lint warnings become fatal errors. This may be drastic, but its use will certainly encourage the development of cleaner AWK programs. With an optional argument ofinvalid, only warnings about things that are actually invalid are issued. (This is not fully implemented yet.) -
-n -
–non-decimal-dataRecognize octal and hexadecimal values in input data. Use this option with great caution! -
-N -
–use-lc-numericThis forces gawk to use the locale’s decimal point character when parsing input data. Although the POSIX standard requires this behavior, and gawk does so when–posixis in effect, the default is to follow traditional behavior and use a period as the decimal point, even in locales where the period is not the decimal point character. This option overrides the default behavior, without the full draconian strictness of the–posixoption. -
-O -
–optimizeEnable optimizations upon the internal representation of the program. Currently, this includes just simple constant-folding. The gawk maintainer hopes to add additional optimizations over time. -
-p[prof_file] -
–profile[=prof_file] Send profiling data to prof_file. The default isawkprof.out. When run with gawk, the profile is just a “pretty printed” version of the program. When run with pgawk, the profile contains execution counts of each statement in the program in the left margin and function call counts for each user-defined function. -
-P -
–posixThis turns on compatibility mode, with the following additional restrictions:-
- •
-
