How to Find the List of Directories in a Directory in Linux/Mac OS X?

Anyone who has used command line on a terminal must used the linux command “ls” to list the files and directories in a directory. Simple use “ls” command will list directory and files in a given directory. Often you might want to know only about the directories in a directory.

One can use the command “ls” with “-d” option to get directories within a directory. Here is how to the list of directories

ls -d */

Remember that the above command will not function recursively and list all directories under a directory.