AWK Usage
Input Lines
Each input line is matched against the pattern portion of every pattern-action
statement; the associated action is performed for each matched pattern.
Any filename of the form var=value is treated as an assignment, not a filename,
and is executed at the time it would have been opened if it were a filename.
Variables assigned in this manner are not available inside a BEGIN rule,
and are assigned after previously specified files have been read.
An input line is normally made up of fields separated by white spaces.
(This default can be changed by using the FS built-in variable or the -Fc
option.) The default is to ignore leading blanks and to separate fields
by blanks and/or tab characters. However, if FS is assigned a value that
does not include any of the white spaces, then leading blanks are not ignored.
The fields are denoted $1, $2, ... $0 refers to the entire line.
Pattern-action Statements
A pattern-action statement has the form:
pattern { action }
Either pattern or action may be omitted. If there is no action, the matching
line is printed. If there is no pat-tern, the action is performed on every
input line. Pattern-action statements are separated by newlines or semicolons.
Patterns are arbitrary Boolean combinations ( !, ||, &&, and
parentheses) of relational expressions and regular expressions. A relational
expression is one of the following:
expression relop expressionexpression matchop regular_expression
where a relop is any of the six relational operators in C, and a matchop
is either ~ (contains) or !~ (does not contain). An expression is an arithmetic
expression, a relational expression, the special expression var in array
or a Boolean combination of these.
Regular expressions are as in egrep(1). In patterns they must be surrounded
by slashes. Isolated regular expressions in a pattern apply to the entire
line. Regular expressions may also occur in relational expressions. A pattern
may consist of two patterns separated by a comma; in this case, the action
is performed for all lines between the occurrence of the first pattern
to the occurrence of the second pattern.
The special patterns BEGIN and END may be used to capture control before
the first input line has been read and after the last input line has been
read respectively. These keywords do not combine with any other patterns.
|