猜数字游戏
shell脚本
#!/bin/bash
num=$(shuf -i 10-99 |head -1) #获取随机2位数数字
while :
do
for i in $(seq 3)
do
read -p "请输入你猜的数字大小:" number
if [ $num -gt $number ]
then
echo "猜小了!"
elif [ $num -lt $number ]
then
echo "猜大了!"
else
read -p "恭喜你,猜对了,是否继续玩游戏(y/n):" y
if [ $y == "y" ]
then
break
else
echo -e "欢迎大佬下次在玩!"
exit
fi
fi
done
done