[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: comparison inside [[]] is not numeric comparison?
From: |
Greg Wooledge |
Subject: |
Re: comparison inside [[]] is not numeric comparison? |
Date: |
Thu, 9 Dec 2010 11:41:17 -0500 |
User-agent: |
Mutt/1.4.2.3i |
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
- comparison inside [[]] is not numeric comparison?, john.ruckstuhl, 2010/12/09
- Re: comparison inside [[]] is not numeric comparison?, DennisW, 2010/12/08
- Re: comparison inside [[]] is not numeric comparison?,
Greg Wooledge <=
- Re: comparison inside [[]] is not numeric comparison?, Dennis Williamson, 2010/12/09
- Re: comparison inside [[]] is not numeric comparison?, Andreas Schwab, 2010/12/09
- Re: comparison inside [[]] is not numeric comparison?, Daniel Fleischman, 2010/12/09
- Re: comparison inside [[]] is not numeric comparison?, Pierre Gaston, 2010/12/09