GNU bug report logs - #33577
doc: mention find/stat in ls documentation

Previous Next

Package: coreutils;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Sun, 2 Dec 2018 11:01:02 UTC

Severity: wishlist

Tags: notabug

Full log


Message #23 received at 33577 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>,
 Bob Proulx <bob <at> proulx.com>
Cc: 33577 <at> debbugs.gnu.org
Subject: Re: bug#33577: ls lacks null terminator option
Date: Wed, 5 Dec 2018 11:25:29 +0100
On 12/4/18 9:35 PM, 積丹尼 Dan Jacobson wrote:
> Bob, I remember from my K&R Unix book that ls can be used in scripts.
> In fact that is why
> $ ls
> acts different than
> $ ls | cat
> 
> Plus there are lots of things ls can do that find cannot.
> 
> For instance sorting.

You didn't mention sorting in your original post, but actually that's a
typical post-action which can be glued together the UNIX way via pipes,
using the decorate-process-undecorate pattern:

  $ find -printf '%T@:%p\0' | sort -znr | cut -zd: -f2- | $PRG

with e.g.
  PRG='head -zn1'
to get the newest file.

And yes, if you really want to cater for arbitrary file names with blanks,
newlines, and control character - short: everything apart from '/' and '\0',
or more malicious file names e.g. starting with '-' or '--' to fool scripts,
then it is quite complex by nature to get it right: think about what
you have to do in the consuming $PRG to perform the processing safely.

> Are you saying you want to enhance find(1) to sort its output?

No, because that what 'sort' is for.

Have a nice day,
Berny




This bug report was last modified 6 years and 185 days ago.

Previous Next


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