bug-coreutils
[Top][All Lists]
Advanced

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

bug#14189: ls -d bug ??


From: Eric Blake
Subject: bug#14189: ls -d bug ??
Date: Thu, 11 Apr 2013 15:41:31 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5

On 04/11/2013 03:31 PM, Eric Blake wrote:
> But for a full list of all subdirectory names excluding '.' and '..',
> you need three globs; and either a shell option that suppresses a glob
> that has no match, or ignoring the errors when ls tries to warn you when
> a glob doesn't match:
> 
> Portable (but risks hiding errors):
> $ ls -d */ .[!.]/ .??*/ 2>/dev/null

Be aware that this also runs the risk of generating too long of a
command line if the globs expand to a lot of names; while find
specifically avoids exceeding command line length limits.  On the other
hand, while ls defaults to sorting its output, find does not; so if you
need sorted output, you have to start considering the use of non-POSIX
extensions such as GNU find's -print0 and sort's -z to generate and sort
the list with unambiguous terminators, if you are worried that any of
the names found might contain a newline in the name.

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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