码迷,mamicode.com
首页 > 系统相关 > 详细

[shell]函数+条件表达式

时间:2016-06-07 23:59:59      阅读:467      评论:0      收藏:0      [点我收藏+]

标签:

了解了下shell的函数和case语句:

函数格式:
function(){

}

例子:
function rsyncstart() { 
    if [ "${status1}X" == "X" ];then 
        rm -f $pidfile       
        ${start_rsync}   
        status2=$(ps -ef | egrep "rsync --daemon.*rsyncd.conf" | grep -v grep) 
        if [  "${status2}X" != "X"  ];then 
            echo "rsync service start.......OK"   
        fi 
    else 
        echo "rsync service is running !"    
    fi 
}

 

 

case $1 in
    "start")
    rsyncstart
    ;;
    *)
    echo "123"
esac

[shell]函数+条件表达式

标签:

原文地址:http://www.cnblogs.com/iiiiher/p/5568606.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!