sureshmsi.co.nr

How to list only directories in linux console

Posted by: sureshm on: December 2, 2007

Well, we know how to list files and directories in console. Yes ‘ls’ is enough.

The ‘ls’ will display all files and directories. To list only directories use :

[ myEmpire$]: ls -d */

:) This will do the trick. ;)

To list only directories, use any one of the following commands.

# ls -d */
# ls -l | grep ‘^d’
# ls -p |grep “/”

# find . -type d (Show full hierarchy)
# find . -type d -maxdepth 1 -mindepth 1

# echo */
# echo */ */ (dig deeper)

# tree -d (Show full hierarchy)
# tree -d -L 1
# tree -fid

Leave a Reply

You must be logged in to post a comment.