simple? sh problen

Ian Smith smithi at nimnet.asn.au
Sun May 15 11:30:22 PDT 2005


Hopefully not too OT .. the only silly question being the unasked one ..

How do I test whether a sh argument is an integer or not, so as to avoid
failing on a syntax error from otherwise working code such as:

 [ $3 -lt 10 -o $3 -gt 600 ] && echo "$0 $1 $2: $3 invalid" && exit 1

when $3 is a non-integer argument?  Do I need to delve into awk and REs,
or is there something more simple I've missed in mans test, expr, etc?

Cheers, Ian



More information about the freebsd-questions mailing list