Question about 'test' (Was Re: testing if a file is present)

Guy Harris guy at auspex.auspex.com
Fri Nov 30 06:04:36 AEST 1990


>But what will the (bourne-) shell say about...
>>
>>        if [ -r filename ]; then

It'll say "OK, this 'if' is going to run the command named '[', passing
it '-r' as its first argument, 'filename' as its second argument, and
']' as its third argument."

"test"/"[" will then say "well, I was invoked as '[' rather than 'test';
that means I should check to make sure my last argument is ']', and
complain otherwise."



More information about the Comp.unix.shell mailing list