[PLUG] not embarassed to ask a basic
Paul Mullen
pm at nellump.net
Sun Oct 7 20:09:52 UTC 2007
On Sun, Oct 07, 2007 at 12:15:16PM -0700, Richard M Lidzbarski (Rick) wrote:
> How do you use the ls command to list ONLY directories, no files?
I don't know that ls has a simple way to list only directories, but
there are a few workarounds:
1. ls -F | grep /
The "-F" option appends an extra character to non-file entries, making
it easier to distinguish them. Directories earn a slash. grep can be
used to filter out anything that doesn't have a slash.
2. find -maxdepth 1 -type d
The "-maxdepth 1" option is necessary to keep find from searching all
the way down the file system tree. The "-type d" option lists only
directories (surprise!).
--
Paul
More information about the PLUG
mailing list