sureshmsi.co.nr

  • 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

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: