[root@master ~]# cat guess.sh
#!/bin/bash
prive=$(expr $RANDOM % 1000)
echo $prive
count=1
while true
do
read -p “请输入一个1-1000的随机数:” num
if [ $num -gt $prive ]; then
echo “大了”
elif [ $num -lt $prive ]; then
echo “小了”
else
echo “两个数相等”
echo $count
exit 0
fi
let count++
done