test for directory

Dave Ihnat dihnat at dminet.com
Tue Aug 18 14:26:31 UTC 2009


On Tue, Aug 18, 2009 at 06:03:14PM +0400, TYURIN Aleksey wrote:
> 
> If [ -d /path/a -a -d /path/b]

I'd suggest being careful posting help to the list before checking
it--many who ask for aid won't catch syntax errors.  That snippet would
fail with the right bracket snuggled up against the 'b'.

Also, it's always much safer to specify multiple tests with enclosing
escaped brackets to guarantee proper association, e.g., for your
example:

  if [ \( -d /path/a \) -a \( -d /path/b \) ]

Cheers,
--
	Dave Ihnat
	dihnat at dminet.com




More information about the redhat-list mailing list