[Date Prev][Date
Next][Thread Prev][Thread Next][Date
Index][Thread Index]
RE: [OT]Bash Script help
- To: <ukha_d@xxxxxxx>
- Subject: RE: [OT]Bash Script help
- From: "Dean Smith" <ukha@xxxxxxx>
- Date: Thu, 5 Jun 2003 23:10:17 +0100
- Mailing-list: list ukha_d@xxxxxxx; contact
ukha_d-owner@xxxxxxx
- Reply-to: ukha_d@xxxxxxx
Thanks Ant
it was as you point out the > and not -gt
Now working just fine !
(aswell as the %2 not $2 - but then I'm showing my Dos colours there!)
Dean
-----Original Message-----
From: Ant [mailto:ant@xxxxxxx]
Sent: 05 June 2003 21:17
To: ukha_d@xxxxxxx
Subject: Re: [ukha_d] [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
** UKHA2004 BE THERE! ** - start planning now.
http://www.automatedhome.co.uk
Post message: ukha_d@xxxxxxx
Subscribe: ukha_d-subscribe@xxxxxxx
Unsubscribe: ukha_d-unsubscribe@xxxxxxx
List owner: ukha_d-owner@xxxxxxx
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Home |
Main Index |
Thread Index
|