shell while循环体猜数字

Posted 旅行者3468号

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell while循环体猜数字相关的知识,希望对你有一定的参考价值。

#! /bin/bash
echo "guest the num from 1 to 10"
read num
while [ $num != 5 ]
do
if [ $num -lt 5 ]
then
echo "Too small,try agin"
read num
elif [ $num -gt 5 ]
then
echo "Too large,try agin"
read num
fi
echo "bingo"
done

  

[[email protected] Desktop]# ./guest.sh 
guest the num from 1 to 10
4
Too small,try agin
5
bingo

  

以上是关于shell while循环体猜数字的主要内容,如果未能解决你的问题,请参考以下文章