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.

Assigning a value to name, and the behavior given for calling export with<br />

arguments are extensions of the P<strong>OS</strong>IX standard.<br />

Related Information<br />

cd, date, set, sh, typeset, vi<br />

expr — Evaluate arguments as an expression<br />

Format<br />

Description<br />

expr –W expression<br />

The set of arguments passed to expr constitutes an expression to be evaluated.<br />

Each command argument is a separate token of the expression. expr writes the<br />

result of the expression on the standard output. This command is primarily intended<br />

for arithmetic and string manipulation on shell variables.<br />

expr supports the following operators. Operators explained together have equal<br />

precedence; otherwise, they are in increasing order of precedence. expr stores an<br />

expression as a string and converts it to a number during the operation. If the<br />

context requires a Boolean value, a numeric value of 0 (zero) or a null string ("") is<br />

false, and any other value is true. Numbers have an optional leading sign. If the -W<br />

option is not specified, numbers are decimal. If the -W option is specified,<br />

expressions may contain octal, hexidecimal, or decimal numbers. expr determines<br />

the base of the number as follows:<br />

v Any number that starts with 0x is hex.<br />

v Any number that starts with 0 is octal.<br />

v Any number that does not start with 0x or 0 is decimal.<br />

Numbers are manipulated as long integers.<br />

expr1 | expr2<br />

Results in the value expr1 if expr1 is true; otherwise, it results in the value<br />

of expr2.<br />

expr1 & expr2<br />

Results in the value of expr1 if both expressions are true; otherwise, it<br />

results in 0.<br />

expr1 = expr2 |<br />

expr1 > expr2<br />

If both expr1 and expr2 are numeric, expr compares them as numbers;<br />

otherwise, it compares them as strings. If the comparison is true, the<br />

expression results in 1; otherwise, it results in 0.<br />

expr1 + expr2 | expr1 – expr2<br />

Performs addition or subtraction on the two expressions. If either<br />

expression is not a number, expr exits with an error.<br />

expr1 * expr2 | expr1 / expr2 | expr1 % expr2<br />

Performs multiplication, division, or modulus on the two expressions. If<br />

either expression is not a number, expr exits with an error.<br />

export<br />

expr1 : re | match expr1 re<br />

matches the regular expression re against expr1 treated as a string. The<br />

regular expression is the same as that accepted by ed, except that the<br />

match is always anchored—that is, there is an implied leading ^. Therefore,<br />

Chapter 2. Shell command descriptions 265

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

Saved successfully!

Ooh no, something went wrong!