[X-Unix] A little shell scripting help

Cloyce D. Spradling cloyce+xunix at headgear.org
Mon Oct 3 15:18:06 PDT 2005


On Mon, Oct 03, 2005 at 05:14:43PM -0400, Mac Daddy wrote:
: 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?

"Why" has already been ably answered. :)

As to what "2:" refers to, it's $retry.  In Bourne shell, you can use
parentheses to run a command in a subshell.  So the shell saw

  if (2>1)

and knew that in order to evaluate the conditional, it would need to run
a program called "2" in a subshell.  So your syntax wasn't bad (except that
it didn't do what you wanted), and the error message is just telling you
that it can't find any program named "2".

--
Cloyce


More information about the X-Unix mailing list