Subject: Re: ls -d (micro) dot
To: None <netbsd-help@netbsd.org>
From: Soren Jacobsen <devsoren@attbi.com>
List: netbsd-help
Date: 02/08/2003 15:31:25
On Sat, Feb 08, 2003 at 06:16:55PM -0500, Gan Uesli Starling wrote:
> I haven't used the '-d' option for 'ls' in a while, but on both of my
> NetBSD 1.6 boxes all I get is the 'dot directory' listed by "ls -d" even
> when there are a whole bunch of directories just wanting to be listed.
>
> Per 'man ls' I read the following...
>
> -d Directories are listed as plain files (not searched
> recursively) and symbolic links in the argument list are not indirected
> through.
>
> ...and it says "Directories are listed" which is plural, meaning more
> than just the dot directory. I am supposing...is this a bug?
This is not a bug.
The current working directory is the default argument (not argument, but
I can't really think of a more appropriate word at the moment). -d does
not recursively list things, so . is all that ls -d is supposed to look
at. It's not useful for finding directories. You can use find for that.
It _is_ useful when you want to look at the contents of some populated
directory. For instance:
soren@bob:/usr/pkgsrc$ ls chat/*icq*
chat/centericq:
CVS/ DESCR Makefile PLIST distinfo
chat/icqlib:
CVS/ DESCR Makefile PLIST distinfo
chat/kicq:
CVS/ DESCR Makefile PLIST distinfo patches/
chat/micq:
CVS/ DESCR Makefile PLIST distinfo patches/
chat/vicq:
CVS/ DESCR Makefile PLIST distinfo patches/
But, we can simplify that output with -d:
soren@bob:/usr/pkgsrc$ ls -d chat/*icq*
chat/centericq/ chat/icqlib/ chat/kicq/ chat/micq/ chat/vicq/
--
Soren Jacobsen