#!/bin/bash
NR=$[RANDOM%100];
reg='[1-9]|[0-9]{2}|100';
echo $NR;
while :
do
read -p "input a number in 1 to 100 :" inum;
if [[ ! "$inum" =~ $reg ]]; then
echo "input err!";
continue;
fi
if [[ $inum -gt NR ]]; then
echo "too big";
continue;
fi
if [[ $inum -lt NR ]]; then
echo "too small";
continue;
fi
if [[ $inum -eq NR ]]; then
echo "yes";
break;
fi
done
NR=$[RANDOM%100];
reg='[1-9]|[0-9]{2}|100';
echo $NR;
while :
do
read -p "input a number in 1 to 100 :" inum;
if [[ ! "$inum" =~ $reg ]]; then
echo "input err!";
continue;
fi
if [[ $inum -gt NR ]]; then
echo "too big";
continue;
fi
if [[ $inum -lt NR ]]; then
echo "too small";
continue;
fi
if [[ $inum -eq NR ]]; then
echo "yes";
break;
fi
done