#!/bin/bash
#this is a example
#5/14/11
RAN=`expr $RANDOM % 10` #产生随机数
RAN=`expr $RAN + 1`
echo "This is a guessing game."
echo "Number range:1-10"
while true
do
echo -n "Please enter the number you think:"
read NUM
if [ $NUM -lt 1 ] || [ 10 -lt $NUM ]
then
echo "You enter the number out of range."
continue
fi
if [ $NUM = $RAN ]
then
echo "You guessed it."
unset NUM RAN
exit 0
fi
if [ $NUM -lt $RAN ]
then
echo "You enter the number is too small."
else
echo "You enter the number is too large."
fi
done
#this is a example
#5/14/11
RAN=`expr $RANDOM % 10` #产生随机数
RAN=`expr $RAN + 1`
echo "This is a guessing game."
echo "Number range:1-10"
while true
do
echo -n "Please enter the number you think:"
read NUM
if [ $NUM -lt 1 ] || [ 10 -lt $NUM ]
then
echo "You enter the number out of range."
continue
fi
if [ $NUM = $RAN ]
then
echo "You guessed it."
unset NUM RAN
exit 0
fi
if [ $NUM -lt $RAN ]
then
echo "You enter the number is too small."
else
echo "You enter the number is too large."
fi
done