Home >> List Directory Only in Bash

Tag: bash

List Directory Only in Bash

To list directory only in Bash using ls use:

ls -d */

from bash help:

-d, –directory will list directories themselves, not their contents

and */ means match all files and sub directories.

so to list all sub directories under /dir/subdir/, you can use:

ls -d /dir/subdir/*/

Similarly, to list all directories including hidden one use:

ls -d .*/ */