SPUG: Multiple uses of <STDIN> in a script?

Kevin Fink kevin at n2h2.com
Sat Oct 16 09:49:29 CDT 1999


On Fri, 15 Oct 1999, Tim Maher/CONSULTIX wrote:

> What exactly do you mean by "xargs interferes with STDIN"?  The only
> drawback I see is that "find . -print | xargs perl_script_taking_args"
> would execute an unpredictable number of separate instances of the
> perl script (each being invoked with the maximum permitted number of
> arguments), which might be less desirable than a single instance reading
> an "infinite" amount of pipeline input.  However, in cases like
> 	find . -print | xargs chmod o-r
> this issue of separate instances being run is of no concern whatsoever!

The -n option to xargs will take care of that problem:

find . -print | xargs -n1 perl_script_takingargs

(However, I agree that it's better to just fix the Perl script.)

Kevin

------------------------------------------------------------------------------
 Kevin Fink <kevin at n2h2.com>          N2H2, Creators of Bess and Searchopolis
 Chief Technology Officer             900 Fourth Avenue, Suite 3400
 http://www.n2h2.com/                 Seattle, WA 98164
 VOICE: 206-336-1501 / 800-971-2622   FAX: 206-336-1541
------------------------------------------------------------------------------


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list