[sh]函数+条件表达式

了解了下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
posted @ 2016-06-07 22:50  _毛台  阅读(570)  评论(0)    收藏  举报