[plug] Shell Scripting Confusion

Nick Bannon nick at ucc.gu.uwa.edu.au
Thu Feb 10 11:00:00 WST 2000


On Wed, Feb 09, 2000 at 02:26:11PM +0800, John Summerfield wrote:
[...]
> It's nothing to do with the question at hand, BUT
> 
> In this context
> 	[ $n > $y ]
> the greather-than symbol is a redirection operator.

">" is not a valid operator to the "test" program. You're looking for
"-gt".

The "test" program is also known as "[", so unless your shell does it
for you (as it often does) ;

  [ "$n" -gt "$y" ] && echo larger || echo smaller

means "run the [ program with the parameters "$n" -gt "$y" ], if
successful run "echo larger" OR if all of the following failed, run
"echo smaller". The final ] is mainly cosmetic.

  test "$n" -gt "$y" && echo larger || echo smaller

works just the same.

Nick.

-- 
  Nick Bannon  | "I made this letter longer than usual because
nick at it.net.au | I lack the time to make it shorter." - Pascal



More information about the plug mailing list