Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Cc: Daniel D Jones <ddjones@××××××××××××.org>
Subject: Re: [gentoo-user] xargs and rm funkiness
Date: Sat, 29 May 2010 19:03:18
Message-Id: 201005292059.16662.alan.mckinnon@gmail.com
In Reply to: Re: [gentoo-user] xargs and rm funkiness by Daniel D Jones
1 On Saturday 29 May 2010 17:05:34 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? TMTOWTDI (There's More Than One Way To Do It) applies just as strongly
12 > to *nix in general as it does to Perl. When there are multiple ways to do
13 > something, it's often either a user preference issue or the method should
14 > be decided based upon the particular details of the desired result. -exec
15 > may be a POSIX standard function, but that doesn't mean it must be used
16 > over other options or you're breaking the standard.
17 >
18 > > UNIX introduced -exec {} + 1990 (when David Korn rewrote find(1)
19 > > and it is in the POSIX standared since some time.
20 >
21 > -exec (which potentially has problems with race conditions - -execdir
22 > should almost always be used instead) runs the command once for each file
23 > found. xargs will call the command once for as many files as it can fit on
24 > the command line. For some instances, like rm, that probably isn't
25 > significant. But if you're calling a complex process with lots of files,
26 > the overhead of starting the many extra processes may be significant.
27
28 Perhaps you don't know Joerg yet. When dealing with the man, it's important to
29 know where he's coming from - and that is not "how Linux does stuff"
30
31 He invariably refers to POSIX when mentioning standards. He uses this standard
32 to ensure that his code will work on any *nix platform. This puts him at odds
33 with the Linux crowd sometimes - two very different viewpoints.
34
35 It's not "-exec" that causes one processto be launched per item found, it is
36 "-exec \;"
37
38 He referred to "-exec +" which has the same behaviour as you mention - use as
39 many filenames as will fit on the command line.
40
41
42 --
43 alan dot mckinnon at gmail dot com

Replies

Subject Author
Re: [gentoo-user] xargs and rm funkiness Daniel D Jones <ddjones@××××××××××××.org>