GAWK
Section: Utility Commands (1)
Updated: May 28 1991
Index
Return to Main Contents
NAME
gawk - pattern scanning and processing language
SYNOPSIS
gawk
[
-W
gawk-options
] [
-Ffs
] [
-v
var=val
]
-f
program-file
[
--
] file ...
gawk
[
-W
gawk-options
] [
-Ffs
] [
-v
var=val
] [
--
]
program-text
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.2 Command Language And Utilities Standard
(draft 11).
This version in turn is based on the description in
The AWK Programming Language,
by Aho, Kernighan, and Weinberger,
with the additional features defined in the System V Release 4 version
of UNIX
awk.
Gawk
also provides some GNU-specific extensions.
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.
OPTIONS
Gawk
accepts the following options, which should be available on any implementation
of the AWK language.
- -Ffs
-
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 POSIX programs.
Following the POSIX 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:
- compat
-
Run in
compatibility
mode. In compatibility mode,
gawk
behaves identically to UNIX
awk;
none of the GNU-specific extensions are recognized.
-
-
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:
-
- *
-
\x
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.
AWK PROGRAM EXECUTION
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-files
had been concatenated together. This is useful for building libraries
of AWK functions, without having to include them in each new AWK
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- OPTIONS
-
- AWK PROGRAM EXECUTION
-
This document was created by
man2html,
using the manual pages.
Time: 11:57:06 GMT, September 19, 2022