5

I want to list only those directories which are a particular depth from current directory. Let's say depth=2

The directories listed can be:

./abc/abc
./xyz/xyz

If depth is 3

./mvd/123/abc

etc.

muru
  • 72,889

2 Answers2

9

find allows you to specify both a minimal and maximal recursion depth:

find . -mindepth 3 -maxdepth 3 -type d
4

Assuming that the depth is 2. You can use

find . -type d -maxdepth 2 -mindepth 2

Here type d option will list only directory.

maxdepth 2 and mindepth 2 will give all the directories and files with exact depth of 2.

Prvt_Yadav
  • 5,882