I want to list only the directories in specified path (ls
doesn\'t have such option).
Also, can this be done with a single line command?
The answer will depend on your shell.
In zsh
, for example, you can do the following:
echo *(/)
And all directories within the current working directory will be displayed.
See man zshexpn for more information.
An alternative approach would be to use find(1)
, which should work on most Unix flavours:
find . -maxdepth 1 -type d -print
find(1) has many uses, so I'd definitely recommend man find
.