1 a=8
2
3 # 下面所有的比较是等价的.
4 test "$a" -lt 16 && echo "yes, $a < 16" # "与列表"
5 /bin/test "$a" -lt 16 && echo "yes, $a < 16"
6 [ "$a" -lt 16 ] && echo "yes, $a < 16"
7 [[ $a -lt 16 ]] && echo "yes, $a < 16" # 在[[ ]]和(( ))中不必用引号引起变量
8 (( a < 16 )) && echo "yes, $a < 16" #
9
10 city="New York"
11 # 同样,下面的所有比较都是等价的.
12 test "$city" \< Paris && echo "Yes, Paris is greater than $city" # 产生 ASCII 顺序.
13 /bin/test "$city" \< Paris && echo "Yes, Paris is greater than $city"
14 [ "$city" \< Paris ] && echo "Yes, Paris is greater than $city"
15 [[ $city < Paris ]] && echo "Yes, Paris is greater than $city" # 不需要用引号引起$city.
16
17 # 多谢, S.C. |