emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#21218: closed (ls -d)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#21218: closed (ls -d)
Date: Sat, 08 Aug 2015 03:44:02 +0000

Your message dated Fri, 7 Aug 2015 21:43:30 -0600
with message-id <address@hidden>
and subject line Re: bug#21218: ls -d
has caused the debbugs.gnu.org bug report #21218,
regarding ls -d
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
21218: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21218
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: ls -d Date: Fri, 7 Aug 2015 17:01:06 -0700
Hi,
I believe there is a problem with ls -d (unless the intent is to just list 1 directory).
Say I have a dir mydir, it has directories d1 and d2, and files f1 and f2.
I want to list only d1 and d2.  How do I do that?  I tried ls -d but that doesn't seem to work:
\ls -d mydir
returns: mydir
\ls -d mydir/*
returns: mydir/d1 mydir/d2 mydir/f1 mydir/f2
but f1 and f2 are files.

How can I achieve the following:
\ls ?????? mydir
to return: mydir/d1 mydir/d2



--
Best Regards,
Eddie Sneeh

--- End Message ---
--- Begin Message --- Subject: Re: bug#21218: ls -d Date: Fri, 7 Aug 2015 21:43:30 -0600 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0
tag 21218 notabug
thanks

On 08/07/2015 06:01 PM, Sneeh, Eddie wrote:
> Hi,
> I believe there is a problem with ls -d (unless the intent is to just list
> 1 directory).

Thanks for the report.  However, I think you have misunderstood the
purpose of -d.  Try this for comparison:

touch file
ls . file
ls -d . file

All -d does is to list command line arguments that are directories as
the name of the directory itself, rather than descending and showing the
directory's contents.

> Say I have a dir mydir, it has directories d1 and d2, and files f1 and f2.
> I want to list only d1 and d2.  How do I do that?  I tried ls -d but that
> doesn't seem to work:
> \ls -d mydir
> returns: mydir
> \ls -d mydir/*
> returns: mydir/d1 mydir/d2 mydir/f1 mydir/f2
> but f1 and f2 are files.

If you want to list ONLY directories, use a glob that guarantees only
directories can be matched:

ls -d mydir/*/

The trailing slash can only match directories, and will therefore skip
ordinary files.  Or, you can use find:

find mydir -mindepth 1 -maxdepth 2 -type d

I'm closing this as not a bug as ls is working as designed, but feel
free to ask further questions.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]