16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

awk<br />

If two expressions are not separated by an operator, awk concatenates their string<br />

values.<br />

The tilde operator ~ yields 1 (true) if the regular expression on the right side<br />

matches the string on the left side. The operator !~ yields 1 when the right side has<br />

no match on the left. To illustrate:<br />

$2 ~ /[0-9]/<br />

selects any line where the second field contains at least one digit. awk interprets<br />

any string or variable on the right side of ~ or !~ as a dynamic regular expression.<br />

The relational operators are =, ==, and !=. When both operands in a<br />

comparison are numeric, or if one is numeric and the other is not initialized, awk<br />

compares their values numerically; otherwise, it compares them as strings. An<br />

operator is considered to be numeric if it consists of any of the following:<br />

v An integer or floating-point number<br />

v A field, FILENAME, ARGV array element, or ENVIRON array element that looks<br />

like a number<br />

v A variable created by a command-line assignment that looks like a number<br />

v Input from a getline() function that looks like a number<br />

v An array element created by the split() function that looks like a number<br />

v A variable assignment from another number variable that looks like a number<br />

The Boolean operators are || (or), && (and), and ! (not). awk uses short-circuit<br />

evaluation when evaluating expressions. With an && expression, if the first operator<br />

is false, the entire expression is false and it is not necessary to evaluate the second<br />

operator. With an || expression, a similar situation exists if the first operator is true.<br />

You can assign values to a variable with:<br />

var = expr<br />

If op is a binary arithmetic operator, var op= expr is equivalent to var = var op expr,<br />

except that var is evaluated only once.<br />

See Table 2 for the precedence rules of the operators.<br />

Table 2. The Order of Operations for awk<br />

Operators Order of operations<br />

(A) Grouping<br />

$i V[a] Field, array element<br />

V++ V-- ++V --V Increment, decrement<br />

A^B Exponentiation<br />

+A -A !A Unary plus, unary minus, logical NOT<br />

A*B A/B A%B Multiplication, division, remainder<br />

A+B A-B Addition, subtraction<br />

A B String concatenation<br />

AB A=B A!=B A==B Comparisons<br />

A~B A!~B Regular expression matching<br />

A in V Array membership<br />

A && B Logical AND<br />

36 z/<strong>OS</strong> <strong>V1R9.0</strong> <strong>UNIX</strong> <strong>System</strong> <strong>Services</strong> <strong>Command</strong> Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!