[Top][All Lists]

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

Re: add find -limit, xargs --limit

From: James Youngman
Subject: Re: add find -limit, xargs --limit
Date: Sun, 13 Nov 2016 03:55:36 +0000

On Sat, Nov 12, 2016 at 11:57 PM, 積丹尼 Dan Jacobson <address@hidden> wrote:
> Gentlemen,

Many of us are not gentlemen, of course!

> just like the SQL language has a "LIMIT" operator

It also has ORDER BY, which is why LIMIT is useful.

> so also does find need a -limit (and xargs a --limit) option.

For cases where only one result is expected (such as -inum, sometimes,
or  "find plain-file-name -ls") there is -quit.

> You might ask can't one just use e.g.,
> $ find|sed 3q

What is the use case answered by this command?   To retrieve an
arbitrary (though not random) selection of three results?

> $ some_command|sed 3q|xargs ...
> and e.g.,
> $ find -print0 | perl -0nwe 'print; exit if $. == 3;' | xargs -0 ...
> if needing to use nulls.
> Well yes one can, but
> 1. at least give the null example on the man pages.
> 2. wouldn't it be much more efficient if the commands stopped output
> themselves? Like
> $ find -limit 3 -print0 | xargs -0 ...
> or
> $ any_command | xargs --limit 3

This email is intended solely for the use of its addressee, sender,
and any readers of a mailing list archive in which it happens to
appear.   If you have received this email in error, please say or type
three times, "I believe in the utility of email disclaimers," and then
reply to the author correcting any spellings (and, optionally, any
incorrect spellings), accompanying these with humorous jests about the
author's parentage.   If you are not the addressee, you are
nevertheless permitted to both copy and forward this email since
without such permissions email systems are unable to transmit email to
anybody, intended recipient or not.  To those still reading by this
point, the author would like to apologise for being unable to maintain
a consistent level of humour throughout this disclaimer.  Contents may
settle during transit.  Do not feed the animals.

reply via email to

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