When you do [tt]ls -l[/tt], lines with a directory begin with a [tt]d[/tt], so you can grep those out.
Code:
ls -l |grep ^d
Or, if you want more control over how you list stuff:
Code:
find . -type d -maxdepth 1 -print0 |xargs -0 ls -d
and pass any options you want to [tt]ls[/tt]. If you plan to use that often, you'll probably want to make a shell alias or function for it.
That line says, "Find everything in this directory -- but no deeper ([tt]-maxdepth 1[/tt]) -- that's a directory ([tt]-type d[/tt]), and print it ([tt]-print0[/tt]). Then, run [tt]ls -d[/tt] and give it all of those files as arguments. The [tt]-print0[/tt] and [tt]-0[/tt] ensure that directory names with spaces are handled properly.
Also, if you use my above command and get warnings, that's because I should have put [tt]-maxdepth 1[/tt] ahead of [tt]-type d[/tt]. Just switch those two around and you won't get the warnings.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.