if test $# = 3
then
case $2 in
+) let z=$1+$3;;
-) let z=$1-$3;;
/) let z=$1/$3;;
x|X) let z=$1*$3;;
*) echo Warning - $2 invalied operator, only +,-,x,/ operator allowed
exit;;
esac
echo Answer is $z
What is the usage of let statement? I have never come across the same. Please let me know the usage, syntax and the need.
Instead of using the let statement above, we could have directly used
case $2 in
+) z=$1+$3;;
-) z=$1-$3;;
/) z=$1/$3;;
x|X) z=$1*$3;;
Then what is the need of using "let" here or anywhere else?