From owner-freebsd-questions@FreeBSD.ORG Sat Aug 13 15:13:31 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 20D4D16A41F for ; Sat, 13 Aug 2005 15:13:31 +0000 (GMT) (envelope-from smithi@nimnet.asn.au) Received: from gaia.nimnet.asn.au (nimbin.lnk.telstra.net [139.130.45.143]) by mx1.FreeBSD.org (Postfix) with ESMTP id BBBE743D45 for ; Sat, 13 Aug 2005 15:13:29 +0000 (GMT) (envelope-from smithi@nimnet.asn.au) Received: from localhost (smithi@localhost) by gaia.nimnet.asn.au (8.8.8/8.8.8R1.4) with SMTP id BAA06253; Sun, 14 Aug 2005 01:13:10 +1000 (EST) (envelope-from smithi@nimnet.asn.au) Date: Sun, 14 Aug 2005 01:13:09 +1000 (EST) From: Ian Smith To: Giorgos Keramidas In-Reply-To: <20050813031912.GB1938@gothmog.gr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Benson Wong , Xu Qiang , freebsd-questions@freebsd.org Subject: Re: Help on bash script? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Aug 2005 15:13:31 -0000 On Sat, 13 Aug 2005, Giorgos Keramidas wrote: > On 2005-08-12 13:38, Benson Wong wrote: > > I prefer: > > > > for COREFILE in `find / -type f -name core -print` > > do > > ... > > done > > > > Wouldn't that accomplish the same thing? > > More or less. Less, when the filenames are too many. See questions > posted on this very same list about ``too many arguments''. True. Of course if you've got that many core files lying around, you probably have other things to worry about :) > The ``while read line; do stuff with $line; done'' loop doesn't suffer > from the same limitation, but is a bit more expensive in terms of the > number of spawned processes and (consequently) the time it takes to run. Maybe measurable. Took me ages to appreciate the difference between say cat tempfile | while read line; do stuff with $line; done and while read line; do stuff with $line; done < tempfile when 'stuff' needs to update script-scope variables, despite a slightly icky, impure feeling about using tempfiles .. cheers, Ian