The program works fine in case " + " ," - "," /"
Example :
./calculate.sh 1 + 2 ==> output is 3.
But the problem here is when I type :
./calculate.sh 1 * 2 ==>output is "Please ..."
I've tried "\*"
like this but it seem the variable $2 can not get what I want.
Anyone can help me what is the problem here ?
#!/bin/sh
if [ $# -ne 3 ]
then
echo "Please input a number , an operator + or - or * or /"
else
case "$2" in
"+") echo "Sum is `expr $1 + $3`";;
"-") echo "Substraction is `expr $1 - $3`";;
"*") echo "Product is `expr $1 \* $3`";;
"/") echo "Division is `expr $1 / $3`";;
esac
fi