1 a=8
2
3 # All of the comparisons below are equivalent.
4 test "$a" -lt 16 && echo "yes, $a < 16" # "and list"
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" # Quoting variables within
8 (( a < 16 )) && echo "yes, $a < 16" # [[ ]] and (( )) not necessary.
9
10 city="New York"
11 # Again, all of the comparisons below are equivalent.
12 test "$city" \< Paris && echo "Yes, Paris is greater than $city" # Greater ASCII order.
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" # Need not quote $city.
16
17 # Thank you, S.C. |