[ale] Bash question...

Geoffrey lists at serioustechnology.com
Sun Jul 22 16:22:40 EDT 2007


Dr. Brian J. Dowd wrote:
> The value of $var is -4.865876
> 
> if [ $var -lt "-4" ];
> 
> throws an "Integer expression expected" error
> 
> Is there a way to test-evaluate a float like -4.865876 ?
> (or I am I trying to get Bash to use non-integers which it can't do without
> some kludge like multiplying all my variables by some arbitrary 1x10^x)

Use a better shell? :)

rhws5hp/home/esoteric> echo $SHELL
/bin/ksh
rhws5hp/home/esoteric> var="-4.865876"
rhws5hp/home/esoteric> if [ $var -lt -4 ]; then date;fi
Sun Jul 22 16:21:49 EDT 2007
rhws5hp/home/esoteric> if [ $var -lt -5 ]; then date;fi
rhws5hp/home/esoteric>

-- 
Until later, Geoffrey

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
  - Benjamin Franklin



More information about the Ale mailing list