Using expr
to evaluate an expression in bash, the following happened
bash-3.2$ expr 1+1
1+1
bash-3.2$ expr 1 + 1
2
Why should the plus sign be padded by space for it to be interpreted as mathematical operation?
Using expr
to evaluate an expression in bash, the following happened
bash-3.2$ expr 1+1
1+1
bash-3.2$ expr 1 + 1
2
Why should the plus sign be padded by space for it to be interpreted as mathematical operation?
I suspect this has little to do with bash. From the man page of expr :
All operators and operands must be passed as separate arguments
In order for operands and operators to be interpreted as separate arguments, You have to separate them (with a space).