[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
原文地址:https://www.cnblogs.com/iiiiher/p/5568606.html