Home >> List Directory Only in Bash

List Directory Only in Bash

Tuesday, March 27th, 2018 | X | How To

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 .*/ */

You might also be interested in: