This is a bash script I made to calculate numbers in Unix:
echo "Please enter the calculation(operation) type (+)(-)(*)(/)"
read $opr
echo "Enter the first number"
read $num1
echo "Enter the second number"
read $num2
if [[ $opr = "+" ]]; then
num=$(($num1 + $num2))
echo "The sum is = $num"
elif [[ $opr = "-" ]]; then
num=$(($num1 - $num2))
echo "The sum is = $num"
elif [[ $opr = "*" ]]; then
num=$(($num1 * $num2))
echo "The sum is = $num"
elif [[ $opr = "/" ]]; then
num=$(($num1 / $num2))
echo "The sum is = $num"
fi
It runs, but it outputs "The sum is = ", and doesn't give a number. Can you see anything that is causing this problem?
bash -x.readandechoon the same lines as the preceding line) the script is going to be more readable.read $byread.