bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comparison inside [[]] is not numeric comparison?


From: Daniel Fleischman
Subject: Re: comparison inside [[]] is not numeric comparison?
Date: Thu, 9 Dec 2010 14:49:03 -0500

>From "man bash"

When  used with [[, The < and > operators sort lexicographically
              using the current locale.

You want (( and )):

$ if (( 1000 > 200 )); then echo pass; else echo wierd; fi
pass

Daniel.

On Fri, Nov 19, 2010 at 19:45, john.ruckstuhl <address@hidden>wrote:

> In bash, a comparison inside "[["/"]]" is lexicographic not numeric?
> This isn't what I expected.
> Which part of the documentation would set me straight?  If someone
> could quote the fine manual, that would be great.
>
> $ if [[ 2000 > 200 ]]; then echo pass; else echo wierd; fi
> pass
>
> $ if [[ 1000 > 200 ]]; then echo pass; else echo wierd; fi
> wierd
>
> $ set | grep BASH_VERSION
> BASH_VERSION='3.2.51(24)-release'
>
> Thanks,
> John R.
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]