Sometimes we need to list only directories on Linux (or any other unix). Here are some approaches.
-
List directories using ls and shell wildcard
$ ls -d */ dir1/ dir2/
-
List using ls -l and egrep
$ ls -l | egrep "^d" drwxrwxr-x 2 user1 staff 68 Feb 17 22:55 dir1 drwxrwxr-x 2 user1 staff 68 Feb 17 22:55 dir2