首页 > 系统服务 > 详细

shell while循环体猜数字

时间:2016-12-13 06:31:30      阅读:200      评论:0      收藏:0      [点我收藏+]
#! /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

  

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

  

shell while循环体猜数字

原文:http://www.cnblogs.com/leonarcohen/p/6166307.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!