guess(){
((total++))
if [ $a -eq $num ];then
echo "you guess is rigth."
if [ $total -eq 3 ];then
echo "less than three times."
elif [ $total -gt 3 -a $total -lt 5 ];then
echo " less 5"
elif [ $total -eq 6 ];then
echo "it‘s many times."
fi
exit 0
elif [ $a -gt $num ];then
echo "$a is bigger than num"
pear
elif [ $a -lt $num ];then
echo "$a is less than num"
pear
fi
}
main(){
pear
while true;do
guess
done
}
原文:http://blog.51cto.com/546136/2064106