#!/bin/bash
#RANDOM 为系统自带的系统变量,值为 0-32767 的随机数
num=$[RANDOM%100+1]
while :
do
read -p "计算机生成了一个 1-100 的随机数,你猜: " num
if [ $num -eq $num ];then
echo "恭喜,猜对了"
exit
elif [ $num -gt $num ];then
echo "Oops,猜大了"
else
echo "Oops,猜小了"
fi
done