Command-Line Syntax
The syntax for invoking awk has two forms:
awk [options
] 'script
'var
=value file(s)
awk [options
] -fscriptfile var
=value file(s)
You can specify a script directly on the
command line, or you can store a script in a
scriptfile and specify it with
-f
. POSIX awk
allows multiple -f
scripts. Variables can be assigned
a value on the command line. The value can be a string or numeric
constant, a shell variable ($
name
), or a command substitution ('
cmd
'
), but the value is available only after
the BEGIN
statement is
executed.
awk operates on one or more
files. If none are specified (or if -
is specified), awk reads from the standard input.
Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.