**Go forward to Boolean Patterns.**

**Go backward to Regexp.**

**Go up to Patterns.**

Comparison Expressions as Patterns
==================================
"Comparison patterns" test relationships such as equality between
two strings or numbers. They are a special case of expression patterns
(see Expressions as Patterns: Expression Patterns.). They are written
with "relational operators", which are a superset of those in C. Here
is a table of them:
`X < Y'
True if X is less than Y.
`X <= Y'
True if X is less than or equal to Y.
`X > Y'
True if X is greater than Y.
`X >= Y'
True if X is greater than or equal to Y.
`X == Y'
True if X is equal to Y.
`X != Y'
True if X is not equal to Y.
`X ~ Y'
True if X matches the regular expression described by Y.
`X !~ Y'
True if X does not match the regular expression described by Y.
The operands of a relational operator are compared as numbers if they
are both numbers. Otherwise they are converted to, and compared as,
strings (see Conversion of Strings and Numbers: Conversion., for the
detailed rules). Strings are compared by comparing the first character
of each, then the second character of each, and so on, until there is a
difference. If the two strings are equal until the shorter one runs
out, the shorter one is considered to be less than the longer one.
Thus, `"10"' is less than `"9"', and `"abc"' is less than `"abcd"'.
The left operand of the `~' and `!~' operators is a string. The
right operand is either a constant regular expression enclosed in
slashes (`/REGEXP/'), or any expression, whose string value is used as
a dynamic regular expression (see How to Use Regular Expressions: Regexp Usage.).
The following example prints the second field of each input record
whose first field is precisely `foo'.
awk '$1 == "foo" { print $2 }' BBS-list
Contrast this with the following regular expression match, which would
accept any record with a first field that contains `foo':
awk '$1 ~ "foo" { print $2 }' BBS-list
or, equivalently, this one:
awk '$1 ~ /foo/ { print $2 }' BBS-list