Gentoo Archives: gentoo-user

From: Etaoin Shrdlu <shrdlu@×××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] xargs and rm funkiness
Date: Sat, 29 May 2010 18:16:52
Message-Id: 201005291904.29190.shrdlu@unlimitedmail.org
In Reply to: Re: [gentoo-user] xargs and rm funkiness by Daniel D Jones
1 On Saturday 29 May 2010, Daniel D Jones wrote:
2 > On Wednesday 26 May 2010 06:42:08 Joerg Schilling wrote:
3 > > Patrick Holthaus <patrick.holthaus@×××××××××××××.de> wrote:
4 > > > You might try:
5 > > >
6 > > > find -name *.ext -print0 | xargs -0 rm
7 > >
8 > > But this is non-standard.
9 >
10 > In what way is this non-standard? That is, what standard is it contrary
11 > to?
12
13 SUS (aka POSIX), although some people are pushing to include -print0 | xargs
14 -0 into the standard. What Joerg meant is that the above construct will only
15 run when using GNU find and xargs. Of course, if you're running Linux, that is
16 probably the case already anyway.
17
18 > TMTOWTDI (There's More Than One Way To Do It) applies just as strongly
19 > to *nix in general as it does to Perl. When there are multiple ways to do
20 > something, it's often either a user preference issue or the method should
21 > be decided based upon the particular details of the desired result. -exec
22 > may be a POSIX standard function, but that doesn't mean it must be used
23 > over other options or you're breaking the standard.
24 >
25 > > UNIX introduced -exec {} + 1990 (when David Korn rewrote find(1)
26 > > and it is in the POSIX standared since some time.
27 >
28 > -exec (which potentially has problems with race conditions - -execdir
29 > should almost always be used instead) runs the command once for each file
30 > found.
31
32 If you use -exec {} + as he wrote, this is not true.
33
34 > xargs will call the command once for as many files as it can fit on
35 > the command line.
36
37 And so does -exec {} +
38
39 > For some instances, like rm, that probably isn't
40 > significant. But if you're calling a complex process with lots of files,
41 > the overhead of starting the many extra processes may be significant.
42
43 See above.

Replies

Subject Author
Re: [gentoo-user] xargs and rm funkiness Joerg.Schilling@fokus.fraunhofer.de (Joerg Schilling)