Need some help with a shell scripting.
This is my code:
while true
do
echo "1. Add"
echo "2. Subtract"
echo "3. Multiply"
echo "4. Divide"
echo "5. Quit"
read -p "Enter your choice: " choice
if [ $choice -eq 5 ]
then
break
fi
number1=$1
number2=$2
read -p "Enter first number: " $number1
read -p "Enter second number: " $number2
if [ $choice -eq 1 ]
then
echo Answer=$(( $number1 + $number2 ))
elif [ $choice -eq 2 ]
then
echo Answer=$(( $number1 - $number2 ))
elif [ $choice -eq 3 ]
then
echo Answer=$(( $number1 * $number2 ))
elif [ $choice -eq 4 ]
then
echo Answer=$(( $number1 / $number2 ))
else
continue
fi
done
And I receiving this error message:
bob@caleston-lp10:~$ ./calculator.sh
Add
Subtract
Multiply
Divide
Quit
Enter your choice: 1
Enter first number: 2
Enter second number: 3 ./calculator.sh: line 24: + : syntax error: operand expected (error token is "+ ")
I’m trying to figure out what it’s wrong but I don’t see anything wrong with my code, what is the shell scripting concept I’m missing?