The expr
command evaluates a given expression and displays its corresponding output. It is used for basic operations like addition, subtraction, multiplication, division, and modulus on integers and Evaluating regular expressions, string operations like substring, length of strings etc.
expr expression
expr 7 + 14
expr 7 * 8
x=10
y=20
res=`expr $x = $y`
echo $res
expr alphabet : alpha
expr 20 % 30
a=HelloWorld
b=`expr substr $a 6 10`
echo $b
Flag | Description |
---|---|
--version |
output version information and exit |
--help |
Display this help and exit |
For more details: Expr on Wikipedia