GNU bug report logs - #46060
Offer ls --limit=...

Previous Next

Package: coreutils;

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

Date: Sat, 23 Jan 2021 23:59:01 UTC

Severity: normal

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Erik Auerswald <auerswal <at> unix-ag.uni-kl.de>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>, 46060 <at> debbugs.gnu.org
Subject: bug#46060: Offer ls --limit=...
Date: Sun, 24 Jan 2021 12:14:44 +0100
Hi Dan,

On 23.01.21 22:13, 積丹尼 Dan Jacobson wrote:
> I hereby propose "ls --limit=..."
> 
> $ ls --limit=1 # Would only print one result item:
> A
> 
> You might say:
> "Jacobson, just use "ls|sed q". Closed: Worksforme."
> 
> Ah, but I am talking about items, not lines:

You can use the ls option '-1' to print one item per line:

    $ touch {a..z}
    $ ls -1 | head -n8
    a
    b
    c
    d
    e
    f
    g
    h

You can use 'column' (from package "bsdmainutils" in Debian etc.)
to columnate the result:

    $ ls -1 | head -n8 | column
    a       b       c       d       e       f       g       h

> Indeed, directories might be huge. And any database command already has
> a --limit option these days, and does not rely on a second program to
> trim its output because it can't control itself. Indeed, on some remote
> connections one would only want to launch one program, not two. Thanks.

It might be nice not to have to create all the output that is to be
discarded, especially on remote and/or slow file systems.

The one program requirement could be fulfilled by a script or shell
function.

I am sorry if my email hinders possible acceptation of an implementation
of your suggestion, but I did want to show that there is a workaround
(adding non-GNU software to the mix, though).

Thanks,
Erik




This bug report was last modified 4 years and 112 days ago.

Previous Next


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