首页 > 系统服务 > 详细

linux shell if语句

时间:2016-01-04 22:14:56      阅读:199      评论:0      收藏:0      [点我收藏+]
#!/bin/bash

read -p "please input Y/N"   keyWord

if [ "$keyWord" == "Y" ] || [ "$keyWord" == "y" ] ; then
    echo OK...countinue
fi

if [ "$keyWord" == "N" ] || [ "$keyWord" == "n" ] ; then
    echo Oh interrupt
fi

read -p "input a number : " num

if [ "$num" == "1" ] ; then #分号面有空格是对的,没有空格也是对的,同理分号与then之间也一样。
    echo --- A ---
elif [ "$num" == "2" ];then #
    echo --- B ---
else
    echo --- C ---
fi

 

linux shell if语句

原文:http://www.cnblogs.com/JiangLe/p/5100227.html

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