Because you compare strings according to Lexicographical order and not numbers
You may use [[ 10 -lt 2 ]]
and [[ 20 -lt 2 ]]
. -lt
stands for Less than (<
). For Greater than (>
) -gt
notation can be used instead.
In bash double parenthesis can be used as well for performing numeric comparison:
if ((10 < 2)); then echo "yes"; else echo "no"; fi
The above example will echo no