#!/bin/bash
sjs=$(expr $RANDOM % 100)
count=0
echo $sjs
while :
do
read -ep "请输入一个数字:" num
let count++
echo "$num"
if [ $num -gt $sjs ];then
echo "大了."
elif [ $num -lt $sjs ];then
echo "小了."
else
echo "想等了!"
echo "你总共猜了$count次"
exit
fi
done
效果图