Go forward to BEGIN/END.
Go backward to Expression Patterns.
Go up to Patterns.
Specifying Record Ranges with Patterns
A "range pattern" is made of two patterns separated by a comma, of
the form `BEGPAT, ENDPAT'. It matches ranges of consecutive input
records. The first pattern BEGPAT controls where the range begins, and
the second one ENDPAT controls where it ends. For example,
awk '$1 == "on", $1 == "off"'
prints every record between `on'/`off' pairs, inclusive.
A range pattern starts out by matching BEGPAT against every input
record; when a record matches BEGPAT, the range pattern becomes "turned
on". The range pattern matches this record. As long as it stays
turned on, it automatically matches every input record read. It also
matches ENDPAT against every input record; when that succeeds, the
range pattern is turned off again for the following record. Now it
goes back to checking BEGPAT against each record.
The record that turns on the range pattern and the one that turns it
off both match the range pattern. If you don't want to operate on
these records, you can write `if' statements in the rule's action to
It is possible for a pattern to be turned both on and off by the same
record, if both conditions are satisfied by that record. Then the
action is executed for just that record.