Another quick answer to the question I see a lot in search queries on this blog: listing directories in a directory. I take it that this question means showing a list of only the directories and not other files under a certain location of your Unix filesystem.
Using find to show only directories
find command helps you show only the directories by using a -type d parameter.
Compare the default find output of finding files and directories under /etc/mysql:
ubuntu# find /etc/mysql /etc/mysql /etc/mysql/debian.cnf /etc/mysql/conf.d /etc/mysql/my.cnf /etc/mysql/debian-start
To the one which only shows you the directories:
ubuntu# find /etc/mysql -type d /etc/mysql /etc/mysql/conf.d
And if you're in doubt, you can always use ls -ld command to confirm that returned entries are really standard Unix directories:
ubuntu# ls -ld /etc/mysql /etc/mysql/conf.d drwxr-xr-x 3 root root 4096 2008-03-28 07:56 /etc/mysql drwxr-xr-x 2 root root 4096 2008-03-25 21:06 /etc/mysql/conf.d
That's it! Have fun with Unix!
- How to Find a Location of a Directory in Unix
- Unix Commands: find
- How To Find the Largest Files in Your Unix