#!/bin/bash
n=$(echo $((RANDOM%100+1)))
echo $n
while :
do
read -p "请输入1-100以内的数字: " n1
if [ -z "$n1" ];then
echo "必须要输入一个数字,请重试!!"
continue
fi
n2=`echo "$n1" | sed 's/[0-9]//g'`
if [ -n "$n2" ];then
echo "输入的不是纯数字,请重试!!"
continue
else
if [ $n -gt $n1 ];then
echo "你猜的数字小了。。。"
continue
elif [ $n -lt $n1 ];then
echo "你猜的数字大了。。。"
continue
else
echo "你猜的数字对了,恭喜你。。。"
break
fi
fi
done