Go to the first, previous, next, last section, table of contents.
A boolean pattern is an expression which combines other patterns using the boolean operators "or" (`||'), "and" (`&&'), and "not" (`!'). Whether the boolean pattern matches an input record depends on whether its subpatterns match.
For example, the following command prints all records in the input file `BBS-list' that contain both `2400' and `foo'.
awk '/2400/ && /foo/' BBS-list
The following command prints all records in the input file `BBS-list' that contain either `2400' or `foo', or both.
awk '/2400/ || /foo/' BBS-list
The following command prints all records in the input file `BBS-list' that do not contain the string `foo'.
awk '! /foo/' BBS-list
Note that boolean patterns are a special case of expression patterns (see section Expressions as Patterns); they are expressions that use the boolean operators. See section Boolean Expressions, for complete information on the boolean operators.
The subpatterns of a boolean pattern can be constant regular
expressions, comparisons, or any other awk expressions. Range
patterns are not expressions, so they cannot appear inside boolean
patterns. Likewise, the special patterns BEGIN and END,
which never match any input record, are not expressions and cannot
appear inside boolean patterns.
Go to the first, previous, next, last section, table of contents.