Sheldon Hearn <[EMAIL PROTECTED]> wrote:
 > On Sat, 21 Apr 2001 16:51:24 +0200, Oliver Fromme wrote:
 > > That can overflow your shell's command line limit (at the
 > > "for" command).  True, our /bin/sh doesn't has such a
 > > limit, AFAIK, but there _are_ shells that do).
 > That's actually my point.  What's being proposed is a non-standard
 > extension to work around a problem on a system that already doesn't have
 > the problem.

Maybe I didn't make myself clear enough.
We _do_ have a problem.

Not all users use /bin/sh.  Scripts needn't be written
in /bin/sh, and xargs can be used interactively, too (I
use it a lot).  Just because _our_ xargs works fine with
_our_ /bin/sh doesn't mean there is no problem.

And then there's the gross efficiency problem.  Try these
alternatives and compare how long they take:

   for i in `find /usr/ports -type f`; do
      cat $i >/dev/null

   find /usr/ports -type f | xargs cat >/dev/null

The latter is a hell of a lot faster.  (The example uses
"cat" just because it works with xargs.)

By the way, the first (inefficient) approach could be
rewritten like this:

   find /usr/ports -type f | while read i; do
      cat $i >/dev/null

This avoid the potential line limit problem, but of course
it's just as inefficient.


Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"All that we see or seem is just a dream within a dream" (E. A. Poe)

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to