MPE/iX Shell and Utilities Reference Manual, Vol 1
awk(1) MPE/iX Shell and Utilities awk(1)
NAME
awk — data transformation, report generation language
SYNOPSIS
awk [–F ere][–f prog][–v var=value ...] [program][var=value ...] [file ...]
DESCRIPTION
awk is a file-processing language which is well-suited to data manipulation and retrieval of
information from text files. This reference page provides a full technical description of awk.
If you are unfamiliar with the language, you may find it helpful to read the awk Tutorial in the
User’s Guide before reading the following material.
An awk program consists of any number of user-defined functions and rules of the form:
pattern {action}
There are two ways to specify the awk program:
(a) Directly on the command line. In this case, the program is a single command line argu-
ment, usually enclosed in apostrophes (’) to prevent the shell from attempting to expand
it.
(b) By using the –f prog option.
You can only specify program directly on the command line if you do not use any –f prog
arguments.
When you specify files on the command line, those files provide the input data for awk to
manipulate. If you specify no such files or you specify – as a file, awk reads data from the
standard input.
You can initialize variables on the command line using
var=value
You can intersperse such initializations with the names of input files on the command line.
awk processes initializations and input files in the order they appear on the command line.
For example, the command
awk -f progfile a=1 f1 f2 a=2 f3
sets a to 1 before reading input from f1 and sets a to 2 before reading input from f3.
Variable initializations that appear before the first file on the command line are performed
immediately after the BEGIN action. Initializations appearing after the last file are performed
immediately before the END action. For more information on BEGIN and END, see Patterns.
Commands and Utilities 1-17