4

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
  • 69,900
  • 13
  • 192
  • 292
sidharth arya
  • 303
  • 3
  • 8

2 Answers2

8

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

find . -mindepth 3 -maxdepth 3 -type d
Ulrich Schwarz
  • 15,669
  • 4
  • 47
  • 58
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,732
  • 7
  • 32
  • 48