How To List Directories in a Directory in Unix
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:
To the one which only shows you the directories:
And if you’re in doubt, you can always use ls -ld command to confirm that returned entries are really standard Unix directories:
That’s it! Have fun with Unix!
See also
- How to Find a Location of a Directory in Unix
- Unix Commands: find
- How To Find the Largest Files in Your Unix
- find command
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:
To the one which only shows you the directories:
And if you’re in doubt, you can always use ls -ld command to confirm that returned entries are really standard Unix directories:
That’s it! Have fun with Unix!
See also
- How to Find a Location of a Directory in Unix
- Unix Commands: find
- How To Find the Largest Files in Your Unix
- find command