zoukankan      html  css  js  c++  java
  • 条件语句练习2

    #!/bin/sbin
    path=/server/scripts
    [ ! -d "$path"] && mkdir $path -p
    
    #menu
    cat <<END        1.[install lamp]
            2.[install lnmp]
            3.[exit]
            pls input the num your want:
    
    END
    read num expr $num + 1 &>/dev/null [ $? -ne 0 ] &&{ echo "the num you input must be {1|2|3}" exit 1 } [ $num == "1" ] &&{ echo "start installing lamp..." sleep 2; [ -x "$path/lamp.sh" ] ||{ echo "$path/lamp.sh does not exist or can not be exec." exit 1 } source $path/lamp.sh exit $? } [ $num == "2" ] &&{ echo "start installing lnmp..." sleep 2; [ -x "$path/lnmp.sh" ] ||{ echo "$path/lnmp.sh dose not exist or can not be exec." exit 1 } source $path/lnmp.sh exit #? } [ $num -eq "3" ] &&{ echo "bye." exit 3 } [[ ! $num =~ [1-3] ]] &&{ echo "the num you input must be {1|2|3}" echo "input error!" exit 4 }
  • 相关阅读:
    Lightoj 1023
    Tju 4119. HDFS
    Lightoj 1020
    Lightoj 1019
    小奇挖矿 2(4和7)
    [AHOI2012]树屋阶梯
    漂亮字串
    Prison 监狱
    2-XOR-SAT
    牛宫
  • 原文地址:https://www.cnblogs.com/vincenshen/p/6554623.html
Copyright © 2011-2022 走看看