From owner-freebsd-questions@FreeBSD.ORG Tue Feb 15 16:30:42 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F409106566C for ; Tue, 15 Feb 2011 16:30:42 +0000 (UTC) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from mail4.sea5.speakeasy.net (mail4.sea5.speakeasy.net [69.17.117.48]) by mx1.freebsd.org (Postfix) with ESMTP id 16AE88FC12 for ; Tue, 15 Feb 2011 16:30:41 +0000 (UTC) Received: (qmail 32513 invoked from network); 15 Feb 2011 16:30:41 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail4.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 15 Feb 2011 16:30:41 -0000 Received: by be-well.ilk.org (Postfix, from userid 1147) id C78B15084F; Tue, 15 Feb 2011 11:30:39 -0500 (EST) From: Lowell Gilbert To: freebsd-questions@freebsd.org References: <3.0.1.32.20110214163437.019167e0@sage-american.com> <12e28896cd5.6574638108640039636.4001582758217268039@zoho.com> <7CD0B68CDB1B3698E9ABE60D@utd71538.local> Date: Tue, 15 Feb 2011 11:30:39 -0500 In-Reply-To: <7CD0B68CDB1B3698E9ABE60D@utd71538.local> (Paul Schmehl's message of "Tue, 15 Feb 2011 09:37:49 -0600") Message-ID: <44mxlxuuog.fsf@be-well.ilk.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: script help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-questions@freebsd.org List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2011 16:30:42 -0000 Paul Schmehl writes: > --On February 15, 2011 12:57:12 PM +0300 Peter Andreev > wrote: > >> Use of "xargs" on many files will be much faster than "find...exec" >> construction >> >> find / -type f -name copyright.htm | xargs sed -i .bak -e 's/2010/2011/g' >> > > I believe you, but can you explain why this is true? What makes xargs > faster than exec? Classically, exec always spun off a new process for each exec (i.e., every single file). For years now, find(1) has had a POSIX-standard syntax (ending the command with a '+' syntax for the end of an -exec line, which does pretty much the same thing in a single command. Sometimes, the command being used only handles one filename at a time, and -exec is necessary.