Shell编程------判断语句

1.  if判断语句:
     整数判断:
            -eq   等于
            -lt    小于
            -gt   大于
            -le   小于等于
            -ge  大于等于
            -ne  不等于
      字符串判断:
            -z   为空
            -n  不为空
            =   等于
            !=  不等于
            >  大于
            <  小于
      逻辑判断:
            -a  并(&&)
            -o  或(||)
#! /bin/bash
read -p "please input: " input    
if [ "${input}" -eq 10 ]; then
    echo "10"
elif [ "${input}" -eq 111 ]; then
    ehco "111"
else
    echo "false"
fi
2.  case判断语句:
#! /bin/bash
read -p "please input: " input
case ${input} in
a) echo "a";;
b) echo "b";;
c) echo "c";;
d) echo "d";;
*) ehco "false";;
esac
 
 
 
            
原文地址:https://www.cnblogs.com/ladawn/p/8412558.html