[Date Prev][Date
Next][Thread Prev][Thread Next][Date
Index][Thread Index]
Re: [OT]Bash Script help
On Thursday 05 June 2003 21:09, Dean Smith wrote:
> if [ "$VAL" > "%2" ]; then
It's doing a string (lexical) comparison, which isn't what you wanted.
You want to use the arithmetic operators (-lt, -gt, -le, -ge, -eq, -ne) and
the $((...)) construct to evaluate your variables as arithmetics. Try
something like this:
#!/bin/bash
val=42;
limit1=50;
limit2=13;
if [ $(($val)) -gt $(($limit1)) ]; then
echo "hurrah!";
else echo "arse!";
fi
if [ $(($val)) -gt $(($limit2)) ]; then
echo "hurrah!";
else echo "arse!";
fi
HTH
ant
--
/\/\
www.ant.org ('') www.ant.org
()
Megawatt Winged Avenger
Home |
Main Index |
Thread Index
|