[ale] Bash question...

Jerald Sheets questy at gmail.com
Sun Jul 22 17:58:20 EDT 2007


Ok, I can do HTML mail...  I can even handle a little color.  But  
PINK and GREEN?

--j


On Jul 22, 2007, at 12:01 PM, Jim Popovitch wrote:

> On Sun, 2007-07-22 at 10:37 -0400, Dr. Brian J. Dowd wrote:
>> The value of $var is -4.865876
>>
>> if [ $var -lt "-4" ];
>>
>> throws an "Integer expression expected" error
>>
>
> The problem is that $var (since it isn't an integer) appears to  
> test ("[") as a string.  So the exception is due to passing a  
> string to -lt which is an operator only used for integer math.
>
> I think the easiest way to make this work is to use bc (man bc).   
> You could do something like the following:
>
>    result=`echo "-4.865876 < -4" | bc`
>
>    if [ $result -eq 0 ]; then
>      echo "Equal or Greater Than"
>    elif [ $result -eq 1 ]; then
>      echo "Less Than"
>
>
> -Jim P.
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale

-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list