[X-Unix] A little shell scripting help

Mac Daddy macdaddee at gmail.com
Mon Oct 3 14:14:43 PDT 2005


Hello all,

I've got a more complex script that failing and I've isolated it down  
to one basic part that's in trouble. The following snippet  
exemplifies the problem that my larger project is having.

#!/bin/sh
retry=1
echo $retry
retry=`expr $retry + 1`
echo $retry
if ($retry>1)
then
echo "beep"
fi


Variable "retry" starts out = 1. I echo it.
retry is incremented by 1. I echo that. Good so far.
Getting the right syntax for the the if ... then structure is killing  
me!
"if retry is greater than one then echo "beep" " should result in the  
word ' beep' on the screen. retry=2 at this point.
Instead line 6 [ if ($retry>1) ] fails with a "line 6: 2: command not  
found" error.

Ugh! It's killing me! Why??? And what's the "2:" refer to anyway?


-md



More information about the X-Unix mailing list