in reply to Re^2: Myth busted: Shell isn't always faster than Perl
in thread Myth busted: Shell isn't always faster than Perl

it starts complaining AND skipping filenames with spaces in them

...And that is precisely why find has the -print0 switch and xargs has the -0 (or --null) switch.

find . -type f -print0 | xargs -0 rm
We're building the house of the future together.

Replies are listed 'Best First'.
Re^4: Myth busted: Shell isn't always faster than Perl
by polettix (Vicar) on Jan 05, 2006 at 16:41 UTC
    This leaves the problem of a very big list, in which case the shell (I presume) would refuse to start the xargs side.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.
      You're wrong.

      xargs is smart enough to deal with that. If the argument list would exceed certain limits (may depend on the system and the build to xargs, for some versions of xargs, limits can be set as parameters), as many copies of the program will be fired up as necessary. Limits exist on the number of arguments, and the total length of the arguments.

      Perl --((8:>*
        I remembered working on a Sun some time ago where a pipe with xargs gave problems with too many arguments - but I might have dreamt it.

        OT: I'm quite happy of my wrong answer. It taught me that I had wrong expectations about xargs, and that it will work fine in my Linux box. And others will possibly benefit :)

        Flavio
        perl -ple'$_=reverse' <<<ti.xittelop@oivalf

        Don't fool yourself.