Valay Desai
Valay Desai

Reputation: 3

how to find particular directory exists within a directorty

how to check whether a directory named such as "2012-02-06T00_17_25_25-06_00" exists inside a particular directory ? here the directory name is a combination of date and time.

Upvotes: 0

Views: 877

Answers (2)

Li-aung Yip
Li-aung Yip

Reputation: 12486

If you want to find a directory needle that exists anywhere inside a parent directory /haystack (including as a sub-sub-sub... directory), you could try

find /haystack | grep /needle/

Upvotes: 0

cnicutar
cnicutar

Reputation: 182619

You can just test it:

path=...
name=2012-02-06T00_17_25_25-06_00

if [ -d "$path/$name" ]
then
   echo "$path/$name exists and it's a directory"
fi

Upvotes: 2

Related Questions