我尝试使用sh命令在Git Bash之类的命令上运行它并且运行正常但是当我在Ubuntu终端或Cygwin上尝试它时,我似乎得到了#34;文件的结尾"错误。我在Putty上运行它也在那里工作。呃...帮忙?
operatorloop=y
while [ "$operatorloop" = y ]
do
echo "Choose among the following: "
echo "Addition (+)"
echo "Subtraction (-)"
echo "Multiplication (*)"
echo "Division (/)"
echo "Please enter an operator:"
read op
if [ "$op" = "+" ] # Addition
then
echo "Please enter the first number: "
read num1
echo "Please enter the second number: "
read num2
let result=num1+num2
echo "The sum is = " $result
else
if [ "$op" = "-" ] # Subtraction
then
echo "Please enter the first number: "
read num1
echo "Please enter the second number: "
read num2
let result=num1-num2
echo "The difference is = " $result
else
if [ "$op" = "*" ] # Multiplication
then
echo "Please enter the first number: "
read num1
echo "Please enter the second number: "
read num2
let result=num1*num2
echo "The product is = " $result
else
if [ "$op" = "/" ] # Division
then
echo "Please enter the first number: "
read num1
echo "Please enter the second number: "
read num2
let result=num1/num2
echo "The quotient is = " $result
else
echo "Not an operator."
fi
fi
fi
fi
echo "Do you want to continue? (y)es or (n)o"
read operatorloop
done