01.01.2013 Views

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

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.

EXPR(l) EXPR ( l )<br />

3.<br />

4.<br />

returns the last segment of a path name (i.e., file).<br />

Watch out for I alone as an argument: expr will<br />

take it as the division operator (see BUGS below).<br />

# A better representation of example 2.<br />

expr I l$a : '·*/\(.*\)'<br />

The addition of the I I characters eliminates any<br />

ambiguity about the division operator and<br />

simplifies the whole expression.<br />

expr $VAR : '·*'<br />

returns the number of characters in $V AR.<br />

SEE ALSO<br />

ed(l), sh(l).<br />

EXIT CODE<br />

As a side effect of expression evaluation, expr returns the follow-<br />

ing exit values:<br />

0<br />

1<br />

2<br />

DIAGNOSTICS<br />

syntax error<br />

non-numeric argument<br />

BUGS<br />

if the expression is neither null nor 0<br />

if the expression is null or 0<br />

for invalid expressions.<br />

for operator/operand errors<br />

if arithmetic is attempted on such a<br />

string<br />

After argument processing by the shell, expr cannot tell the<br />

difference between an operator and an operand except by the<br />

value. If $a. is an =, the command:<br />

expr $a = '='<br />

looks like:<br />

expr = = =<br />

as the arguments are passed to expr (and they will all be taken as<br />

the = operator). The following works:<br />

expr X$a = X=<br />

- 2-

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

Saved successfully!

Ooh no, something went wrong!