该程序旨在创建一个随机数并检查它是否小于、大于或等于用户在计数小于 3 时输入的数字。
#!/bin/sh
ranNum=$(($RANDOM % (2 - 1)))
ranNum=$((1 + $ranNum))
c=1
echo "The entity with the greatest number wins"
while [ $c -lt 3 ]
do
echo "Enter a number"
read usrIn
if ["$usrIn" -gt "$ranNum"]
then
echo "You won"
((c++))
if ["$usrIn" -lt "$ranNum"]
then
echo "You lost"
((c++))
else
echo "Its a tie"
((c++))
break
fi
done
当我在 shell 中运行代码时,返回 2 个错误:
第 24 行:意外标记done'
line 24:
完成附近的语法错误
我不确定我的代码语法有什么问题或从这里去哪里。