linux shell 条件判断
(1)是否等于
if [ x"$1" == x"a" ];then echo right else echo wrong fi
(2)多重条件
#!/bin/bash score=$1 if [ $score = 5 ]||[ $score = 3 ];then echo right else echo wrong fi
#!/bin/bash score=$1 if [ $score -gt 5 ]||[ $score -lt 3 ];then echo right else echo wrong fi
(3)elseif
scores=84; if [[ $scores -gt 90 ]]; then echo "very good!"; elif [[ $scores -gt 80 ]]; then echo "good!"; elif [[ $scores -gt 60 ]]; then echo "pass!"; else echo "no pass!"; fi; JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true " JAVA_DEBUG_OPTS="" if [ "$1" = "debug" ]; then JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n " elif [ "$1" = "swing" ]; then JAVA_OPTS=" -Djava.net.preferIPv4Stack=true " APP_MAINCLASS=org.fengfei.lanproxy.client.swing.ClientApp fi