[plug] Shell Scripting Confusion

John Summerfield summer at OS2.ami.com.au
Thu Feb 10 11:40:13 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) ;

test is a bash builtin. -gt and > are different; read the docs.

> 
>   [ "$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.
Read the docs:

[summer at emu summer]$ help [
+ help '['
[: [ arg... ]
    This is a synonym for the "test" builtin, but the last
    argument must be a literal `]', to match the opening `['.
[summer at emu summer]$ 

-- 
Cheers
John Summerfield
http://os2.ami.com.au/os2/ for OS/2 support.
Configuration, networking, combined IBM ftpsites index.





More information about the plug mailing list