List Only Directories on Linux with ls -d */
List only directories with ls -d */, which prints each name with a trailing slash. Symlinks to directories are included and hidden ones are not.
A directory is full of files and you want to see just the subdirectories.
mkdir a "b c" .hidden
touch file
ln -s a link
ls -d */
echo ---
find . -mindepth 1 -maxdepth 1 -type d | sorta/
b c/
link/
---
./.hidden
./a
./b cThe shell expands */ to every name that is a directory, or a symlink to one, and -d makes ls list those names instead of their contents. Without it, ls would open each directory and list what is inside. The pattern skips dotfiles by default, and find -type d does not follow symlinks, so the two commands disagree on link and .hidden as the output shows. The options are in the ls manual.
When there are no subdirectories the glob stays as the literal text */ and ls reports that no such file exists. Check with compgen -G '*/' in Bash or turn on nullglob. A very long list can hit the argument limit, where find has no such limit.