Evaluate expressions.
Synopsis
expr EXPRESSION
Description
Evaluates EXPRESSION and prints the result. Supports arithmetic (+ - \* / %), comparison, and string operators, matching the POSIX expr utility. Each operator and operand must be a separate argument.
Examples
$ expr 3 + 4
Print 7.
$ x=$(expr $x + 1)
Increment a shell variable.
$ P
r
Notes
Operators like *, <, > must usually be escaped or quoted to avoid shell interpretation. Prefer $(( )) arithmetic expansion in bash for simple arithmetic; expr exists mainly for POSIX-shell portability.
See Also
bash, awk