Go forward to Regexp Summary.
Go backward to Rules Summary.
Go up to Rules Summary.

Patterns
--------

   `awk' patterns may be one of the following:

     /REGULAR EXPRESSION/
     RELATIONAL EXPRESSION
     PATTERN && PATTERN
     PATTERN || PATTERN
     PATTERN ? PATTERN : PATTERN
     (PATTERN)
     ! PATTERN
     PATTERN1, PATTERN2
     BEGIN
     END

   `BEGIN' and `END' are two special kinds of patterns that are not
tested against the input.  The action parts of all `BEGIN' rules are
merged as if all the statements had been written in a single `BEGIN'
rule.  They are executed before any of the input is read.  Similarly,
all the `END' rules are merged, and executed when all the input is
exhausted (or when an `exit' statement is executed).  `BEGIN' and `END'
patterns cannot be combined with other patterns in pattern expressions.
`BEGIN' and `END' rules cannot have missing action parts.

   For `/REGULAR-EXPRESSION/' patterns, the associated statement is
executed for each input line that matches the regular expression.
Regular expressions are extensions of those in `egrep', and are
summarized below.

   A RELATIONAL EXPRESSION may use any of the operators defined below in
the section on actions.  These generally test whether certain fields
match certain regular expressions.

   The `&&', `||', and `!' operators are logical "and," logical "or,"
and logical "not," respectively, as in C.  They do short-circuit
evaluation, also as in C, and are used for combining more primitive
pattern expressions.  As in most languages, parentheses may be used to
change the order of evaluation.

   The `?:' operator is like the same operator in C.  If the first
pattern matches, then the second pattern is matched against the input
record; otherwise, the third is matched.  Only one of the second and
third patterns is matched.

   The `PATTERN1, PATTERN2' form of a pattern is called a range
pattern.  It matches all input lines starting with a line that matches
PATTERN1, and continuing until a line that matches PATTERN2, inclusive.
A range pattern cannot be used as an operand to any of the pattern
operators.

   See Patterns, for a full description of the pattern part of `awk'
rules.