From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1OIRJW-0002Vp-FH for garchives@archives.gentoo.org; Sat, 29 May 2010 19:03:18 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2717BE0AB5; Sat, 29 May 2010 19:02:32 +0000 (UTC) Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181]) by pigeon.gentoo.org (Postfix) with ESMTP id DDF9BE0B0C for ; Sat, 29 May 2010 19:02:31 +0000 (UTC) Received: by wyf19 with SMTP id 19so665474wyf.40 for ; Sat, 29 May 2010 12:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:message-id; bh=Oc0XRPJDT3em5k0g+REL80/tDx8o8rik0FXGKkITy4E=; b=EUeVY9gk2wzVo/eUWqStX56qgdzm4wc1YOVknOYoURADqP+WpmDMhN+pbgAFGtAWzD pwVlKEaGcujrAGfM59PkMB6ojyQ6+Ykx0yvM+4ctmHcWGydUs8OEk1nw++HSrLegCdUi nZiT1Luy/jwSQhMVbfxulvKHOoZ+7bPSS62vg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; b=LxVjWYUox/0d/y4tYvwogRIqausuc3HhjZA8RzzViF0PmmCtWBFggyrDDjipPKpOVT NnwKGOXtINovj6iaoYBDxgKJMTEUJV7Naie4MMBHPbLtuCa9WUpzukcM4MbPBPLSHVSX Bmg1ZYKxHZPyrBhj+w8PtHti9wyOVPMINLkMA= Received: by 10.227.156.9 with SMTP id u9mr1999143wbw.27.1275159750291; Sat, 29 May 2010 12:02:30 -0700 (PDT) Received: from nazgul.localnet (196-210-183-217-wbs-esr-2.dynamic.isadsl.co.za [196.210.183.217]) by mx.google.com with ESMTPS id u32sm2207596wbc.11.2010.05.29.12.02.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 29 May 2010 12:02:29 -0700 (PDT) From: Alan McKinnon To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] xargs and rm funkiness Date: Sat, 29 May 2010 20:59:16 +0200 User-Agent: KMail/1.13.3 (Linux/2.6.34-ck; KDE/4.4.3; x86_64; ; ) Cc: Daniel D Jones References: <201005212149.49715.ddjones@riddlemaster.org> <4bfcfb00.9YSnTl2P0CKPNeJN%Joerg.Schilling@fokus.fraunhofer.de> <201005291105.34219.ddjones@riddlemaster.org> In-Reply-To: <201005291105.34219.ddjones@riddlemaster.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201005292059.16662.alan.mckinnon@gmail.com> X-Archives-Salt: 2eb9ab68-2932-4890-bfa3-73636d305290 X-Archives-Hash: d6c8db88c1a45d1c7be61a3588832085 On Saturday 29 May 2010 17:05:34 Daniel D Jones wrote: > On Wednesday 26 May 2010 06:42:08 Joerg Schilling wrote: > > Patrick Holthaus wrote: > > > You might try: > > > > > > find -name *.ext -print0 | xargs -0 rm > > > > But this is non-standard. > > In what way is this non-standard? That is, what standard is it contrary > to? TMTOWTDI (There's More Than One Way To Do It) applies just as strongly > to *nix in general as it does to Perl. When there are multiple ways to do > something, it's often either a user preference issue or the method should > be decided based upon the particular details of the desired result. -exec > may be a POSIX standard function, but that doesn't mean it must be used > over other options or you're breaking the standard. > > > UNIX introduced -exec {} + 1990 (when David Korn rewrote find(1) > > and it is in the POSIX standared since some time. > > -exec (which potentially has problems with race conditions - -execdir > should almost always be used instead) runs the command once for each file > found. xargs will call the command once for as many files as it can fit on > the command line. For some instances, like rm, that probably isn't > significant. But if you're calling a complex process with lots of files, > the overhead of starting the many extra processes may be significant. Perhaps you don't know Joerg yet. When dealing with the man, it's important to know where he's coming from - and that is not "how Linux does stuff" He invariably refers to POSIX when mentioning standards. He uses this standard to ensure that his code will work on any *nix platform. This puts him at odds with the Linux crowd sometimes - two very different viewpoints. It's not "-exec" that causes one processto be launched per item found, it is "-exec \;" He referred to "-exec +" which has the same behaviour as you mention - use as many filenames as will fit on the command line. -- alan dot mckinnon at gmail dot com