On 09/07/07, Jeff Waugh <[EMAIL PROTECTED]> wrote:

<quote who="Amos Shapira">

>> Zhasper> find . -name "<junkfile>" -print0 | xargs -0 rm
>>
>> Actually lighter weight, less forking less execing, because this
version
>> runs two procsses only, rather than a new invocation of rm for each
file
>> found.
>
> It runs at least three processes if it finds any file - "rm" is forked
> from xargs (unless xargs is smart enough to save the fork on end of
> input?)

No, three in total (in common circumstances): One for find, one for xargs,
one for rm. It will invoke more than one rm process if xargs determins
that
the parameter length is too long for a single invocation (or if other
params
altering that behaviour are passed to it, unlike the example provided).


So an enhancement suggestion I have for xargs is that when it reaches EOF on
its input it can skip the "fork" and just "exec" the command given to it
("rm" in the case above). That is, unless there is some xargs option that
requires it to stay behind even the last command (I can't find any from a
cursory look at "man xargs"). I suppose you can look at this as another form
of "tail recursion optimization".

Maybe I'll get around to implement this one day...

--Amos
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to