find . -type d
can be used to find all directories below some start point. But it returns the current directory (.
) too, which may be
POSIX 7 solution:
find . ! -path . -type d
For this particular case (.
), golfs better than the mindepth
solution (24 vs 26 chars), although this is probably slightly harder to type because of the !
.
To exclude other directories, this will golf less well and requires a variable for DRYness:
D="long_name"
find "$D" ! -path "$D" -type d
My decision tree between !
and -mindepth
:
!
for portability..
? Throw a coin.long_name
? Use -mindepth
.