Sometimes, I need to check only the directories not files. Is there any option with the command ls? Or is there any utility for doing that?
EDIT: I'm using Mac OS X, and ls -d gives me . even though I have directories.
|
I know there is already a selected answer, but you can get the requested behavior with just
This will list all the directories in the current working directory where it is run. To get all the subdirectories of some other folder, just try:
Note that the -l is optional. |
|||
|
|
No, but a simple
or
You could then alias either one if necessary. |
||||
|
|
|
I like the tree utility to get an overview over the directory structure. It's available in MacPorts and all Linux distributions I've tried.
That would show all directories, two levels deep. |
|||
|
|
|
I also needed to view hidden directories so have modified the suggestion above to fit my needs
|
||||
|
|
|
I think ls has a bug on Mac OS X. A workaround is to use grep... |
|||||||
|
ls -dgives only.and why the*/must be added to the end to make it work? – cwd Oct 4 '11 at 2:49lsdefaults to.. And-dmeans don't print the directory's contents, print the directory itself. – Mikel May 23 '12 at 14:52ls -pit shows the/after the directory names. So*/is just a pattern which is matched against the directory name and/combo. – Pitt Oct 24 '12 at 15:55