[CentOS] Question about Shell Script.

William L. Maltby CentOS4Bill at triad.rr.com
Fri Jan 30 21:27:53 UTC 2009


On Fri, 2009-01-30 at 15:56 -0500, Filipe Brandenburger wrote:
> On Fri, Jan 30, 2009 at 13:59, R P Herrold <herrold at centos.org> wrote:
> > or for those who are used to being burned:
> >      [ 0$NUMBEROFPRO -gt 150 ]
> 
> Still going to explode if $NUMBEROFPRO contains spaces. Putting in
> double quotes will not help you either, since it will complain about
> it not being numeric...

That taught me long ago, if input was inconsistent, to check for
non-numerics before doing math. Back then, it was the expr command
(still available I think). Now it's some of those builtins accessed with
${} constructs. Expr is simpler, shorter to code and reliable.

> 
> Doing math with the shell is always tricky, almost never robust...
> 
> Filipe
> <snip sig stuff>

-- 
Bill




More information about the CentOS mailing list