| manpages.info - online man pages | ![]() |
|||
|
expr (1) Table of Contents
Nameexpr - evaluate expression
Synopsisexpr expression
DescriptionThe expr utility evaluates expression and writes the result on standard output.
All operators are separate arguments to the expr utility. Characters special to the command interpreter must be escaped.
Operators are listed below in order of increasing precedence. Operators with equal precedence are grouped within { } symbols.
expr1 | expr2
expr1 & expr2
expr1 {=, >, >=, <, <=, !=} expr2
expr1 {+, -} expr2
expr1 {*, /, %} expr2
expr1 : expr2
If the match succeeds and the pattern contains at least one regular expression subexpression ``\(...\)'', the string corresponding to ``\1'' is returned; otherwise the matching operator returns the number of characters matched. If the match fails and the pattern contains a regular expression subexpression the null string is returned; otherwise 0.
Parentheses are used for grouping in the usual manner.
Examples1. The following example adds one to the variable a. a=`expr $a + 1`
2. The following example returns the filename portion of a pathname
stored in variable a. The // characters act to eliminate ambiguity
with the division operator.
3. The following example returns the number of characters in variable
a.
DiagnosticsThe expr utility exits with one of the following values:
StandardsThe expr utility conforms to IEEE Std 1003.2 (``POSIX.2'').
|