#!/bin/bash
number=$[RANDOM%1000]
while true
do
for i in `seq 0 3`
do
if [ $i -eq 3 ]
then
read -ep "已经错了三次 是否继续?(yes/no):" d
if test $d == "yes"
then
let i=0
continue
else
let i=0
echo "再见!"
exit
fi
else
read -ep "输入你猜的数:" c
if [ $c -gt $number ]
then
echo "猜大了!"
let i++
elif test $c -lt $number
then
echo "猜小了!"
let i++
else
echo "猜对了!程序结束了!"
exit
fi
fi
done
done