GNU bug report logs - #14189
ls -d bug ??

Previous Next

Package: coreutils;

Reported by: "ray <at> electronicstheory.com" <ray <at> electronicstheory.com>

Date: Thu, 11 Apr 2013 20:21:02 UTC

Severity: normal

Tags: notabug

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eric Blake <eblake <at> redhat.com>
Cc: "ray <at> electronicstheory.com" <ray <at> electronicstheory.com>, 14189 <at> debbugs.gnu.org, Bob Proulx <bob <at> proulx.com>
Subject: bug#14189: ls -d bug ??
Date: Thu, 11 Apr 2013 15:41:31 -0600
[Message part 1 (text/plain, inline)]
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

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 12 years and 96 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.