我收到基于“然后”的错误。我应该在它前面放些空间吗?
winning=$(( RANDOM % 15 ))
while [[${guess}-ne ${winning}]]; then
read -p "guess a number from 0 to 15: " guess
if [[${guess}-ne ${winning}]]; then
echo "Your guess, ${guess}, was incorrect. Guess again to win a \$200 Guess handbag."
fi
done
echo "Congrats! You got it! ${guess}"
exit 0
您似乎找到了答案,但对于那些在家看电视的人来说,then
仅适用于if语句。在while循环中,您会说do
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句