.\" @(#)expr.1 6.1 (Berkeley) %G%
expr \- evaluate arguments as an expression
The arguments are taken as an expression.
After evaluation, the result is written on the standard output.
Each token of the expression is a separate argument.
The operators and keywords are listed below.
The list is in order of increasing precedence,
with equal precedence operators grouped.
if it is neither null nor `0', otherwise
is null or `0', otherwise yields `0'.
yields `1' if the indicated comparison is true, `0' if false.
The comparison is numeric if both
are integers, otherwise lexicographic.
addition or subtraction of the arguments.
multiplication, division, or remainder of the arguments.
The matching operator compares the string first argument
with the regular expression second argument;
regular expression syntax is the same as that of
pattern symbols can be used to select a portion of the
the matching operator yields the number of characters matched
parentheses for grouping.
To add 1 to the Shell variable
To find the filename part (least significant part)
of the pathname stored in variable
which may or may not contain `/':
expr $a : \'.*/\e(\^.*\e)\' \'\^|\' $a
Note the quoted Shell metacharacters.
returns the following exit codes:
0 if the expression is neither null nor `0',
2 for invalid expressions.