[lug] BASH Arithmetic Evaluation

Sean Reifschneider jafo at tummy.com
Sat Jan 20 21:20:11 MST 2001


On Sat, Jan 20, 2001 at 09:16:40PM -0700, SoloCDM wrote:
>I tried to evaluate an arithmetic value with a while command using
>"while [ ${MANS} >= 4 ]", but it doesn't work . . . why?  Ignore the
>omittance of do through done.

The "[ ]" notation is short-hand for "test".  Do a "help test" to
get more information on the operators.  What you want is '-ge':

	while [ "$MANS" -ge 4 ]

Don't forget to surround it with quotes, or you're get not what you expected
if the MANS isn't set.

Sean
-- 
 Program *INTO* a language, not *IN* it.
                 -- David Gries
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python




More information about the LUG mailing list