expr
: Evaluate expressions
expr
evaluates an expression and writes the result on standard
output. Each token of the expression must be a separate argument.
Operands are either numbers or strings. expr
coerces
anything appearing in an operand position to an integer or a string
depending on the operation being applied to it.
Strings are not quoted for expr
itself, though you may need to
quote them to protect characters with special meaning to the shell,
e.g., spaces.
Operators may given as infix symbols or prefix keywords. Parentheses may be used for grouping in the usual manner (you must quote parentheses to avoid the shell evaluating them, however).
0 if the expression is neither null nor 0, 1 if the expression is null or 0, 2 for invalid expressions.
Go to the first, previous, next, last section, table of contents.