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.
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.
find
allows you to specify both a minimal and maximal recursion depth:
find . -mindepth 3 -maxdepth 3 -type d
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.