begin  quoting John H. Robinson, IV as of Sun, Mar 11, 2007 at 08:43:43PM -0700:
> Urivan Flores-Saaib wrote:
> > > John H. Robinson, IV wrote
> > >>find $HOME/.mozilla -name lock -print0 | xargs -0 rm
> > 
> > Why not:
> > 
> > find $HOME/.mozilla -name lock -exec rm {} \;
> 
> If there is exactly ONE lock file, then this is fine. If there are
> multiple lock files, this forks off one rm for each file found. If there
> are hundreds, well, you get the idea.

Yeah, it'll take an extra two seconds in that case.

> The xargs, while less efficient in the singluar case is far more
> efficient in the multiple case.
 
As you go on to point out, we expect one file.

> For this instance, the -exec rm will be more efficient, as there is only
> one file expected.

The only reason to use xargs for this sort of thing is to get in the
habit of using xargs later, so that when it does make a real difference,
you don't have to look anything up.

This is why you have your student hand-wax your car rather than taking
it to the local car wash.

Arguing for efficiency's sake is just a pissing contest.

-- 
Avoid premature optimization.
Stewart Stremler


-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to