我正在创建一个做一些简单数学运算但无法运行的小程序。它只是输出“文件意外结束”。我似乎找不到错误..?
#!/bin/bash
until [ $second_num -ne 0 ]; do
echo "Enter number 1:"
read first_num
echo "Enter number 2:"
read second_num
echo "Cannot divide by 0. Start over."
done
result=0
if [ $first_num -ne 999 && $second_num -ne 999 ]; then
let result=$((first_num/second_num))
echo $result
echo "Program finished!"
else
echo "You have exited the program."
exit 0
fi
number=1
while [ $number -lt 100 ]; do
echo $number
let number=$(( $number % 5 ))
echo $number >> sample.txt
done