test for directory

Zoran Salahovic Lendra zsalahovic at bankinter.es
Tue Aug 18 14:34:50 UTC 2009


also u can do:

if  test -d /home/ && test -d /var  ; then echo yes; else echo no; fi


Regards,
Zoran




Dave Ihnat <dihnat at dminet.com> 
 
Enviado por: redhat-list-bounces at redhat.com
18/08/2009 16:26
Por favor, responda a
General Red Hat Linux discussion list <redhat-list at redhat.com>


Para
General Red Hat Linux discussion list <redhat-list at redhat.com>
cc

Asunto
Re: test for directory






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

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list




More information about the redhat-list mailing list