Gentoo Archives: gentoo-user

From: Daniel D Jones <ddjones@××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] xargs and rm funkiness
Date: Sat, 29 May 2010 15:06:58
Message-Id: 201005291105.34219.ddjones@riddlemaster.org
In Reply to: Re: [gentoo-user] xargs and rm funkiness by Joerg.Schilling@fokus.fraunhofer.de (Joerg Schilling)
1 On Wednesday 26 May 2010 06:42:08 Joerg Schilling wrote:
2 > Patrick Holthaus <patrick.holthaus@×××××××××××××.de> wrote:
3 > > You might try:
4 > >
5 > > find -name *.ext -print0 | xargs -0 rm
6 >
7 > But this is non-standard.
8
9 In what way is this non-standard? That is, what standard is it contrary to?
10 TMTOWTDI (There's More Than One Way To Do It) applies just as strongly to *nix
11 in general as it does to Perl. When there are multiple ways to do something,
12 it's often either a user preference issue or the method should be decided
13 based upon the particular details of the desired result. -exec may be a POSIX
14 standard function, but that doesn't mean it must be used over other options or
15 you're breaking the standard.
16
17 > UNIX introduced -exec {} + 1990 (when David Korn rewrote find(1)
18 > and it is in the POSIX standared since some time.
19
20 -exec (which potentially has problems with race conditions - -execdir should
21 almost always be used instead) runs the command once for each file found.
22 xargs will call the command once for as many files as it can fit on the command
23 line. For some instances, like rm, that probably isn't significant. But if
24 you're calling a complex process with lots of files, the overhead of starting
25 the many extra processes may be significant.
26
27 --
28 "You have attributed conditions to villainy that simply result from
29 stupidity." - Robert A. Heinlein

Replies

Subject Author
Re: [gentoo-user] xargs and rm funkiness Etaoin Shrdlu <shrdlu@×××××××××××××.org>
Re: [gentoo-user] xargs and rm funkiness Alan McKinnon <alan.mckinnon@×××××.com>