MPE/iX Shell and Utilities Reference Manual, Vol 1

awk(1) MPE/iX Shell and Utilities awk(1)
If two expressions are not separated by an operator, awk concatenates their string values.
The operator ˜ yields 1 (true) if the regular expression on the right side matches the string on
the left side. The operator yields 1 when the right side has no match on the left. To illus-
trate:
$2 ˜ /[0-9]/
selects any line where the second field contains at least one digit. awk interprets any string or
variable on the right side of ˜ or as a dynamic regular expression.
The relational operators are <, <=, >, >=, ==, and !=. When both operands in a comparison
are numeric, awk compares their values numerically; otherwise, it compares them as strings.
An operand is numeric if it is an integer or floating point number, if it is a field or ARGV ele-
ment that looks like a number, or if it is a variable created by a command line assignment that
looks like a number.
The Boolean operators are || (or), && (and), and ! (not). Short Circuit Evaluation is used
when evaluating expressions. With an && expression, if the first operator is false, the entire
expression is false and it is not necessary to evaluate the second operator. With an || expres-
sion, a similar situation exists if the first operator is true.
You can assign values to a variable with
var = expr
If op is a binary arithmetic operator,
var op= expr
is equivalent to
var = var op expr
except that var is evaluated only once.
See Table 1-2, awk Order of Operations for the precedence rules of the operators.
1-22 Commands and Utilities