On Fri, Nov 19, 2010 at 04:45:15PM -0800, john.ruckstuhl wrote:
> In bash, a comparison inside "[["/"]]" is lexicographic not numeric?

Correct.  Assuming you use the string-comparison operators (> and <)
rather than the integer-comparison operators (-gt, -lt, etc.).

> $ if [[ 1000 > 200 ]]; then echo pass; else echo wierd; fi
> wierd

String comparison.  If you want to do numeric comparisons, use ((...))
or use -gt.

if ((1000 > 200)); then echo pass; else echo weird; fi
if [[ 1000 -gt 200 ]]; then echho pass; else echo weird; fi

Reply via email to