[clug] list only directories

Andrew Donnellan andrew at donnellan.id.au
Tue Nov 19 23:32:42 MST 2013


On 20/11/13 17:22, Hal Ashburner wrote:
> I've had it or something like it for years. Never given it much thought,
> but it strikes me as really quite odd that ls, having 16536 different
> options doesn't have one for just show me things of this type. Maybe I just
> missed it? Reading manpages in depth is pretty painful.
>
> Do you good and talented people all do something similar? Are you doing
> better? Have I missed a trick?

http://stackoverflow.com/questions/14352290/listing-only-directory-using-ls-in-bash
suggests "ls -d */" (or more generally, "ls -d [PATH]/*/"), using the -d
flag to ensure it lists the directory entry itself rather than its
contents, and bash will match */ to directories only. This does add
trailing /s in the output which your script doesn't.

"find -type d" is also useful to know.


Andrew


More information about the linux mailing list