From owner-freebsd-questions Wed Apr 17 21:43:54 2002 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id 37F6B37B400 for ; Wed, 17 Apr 2002 21:43:50 -0700 (PDT) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.12.2/8.12.2) with ESMTP id g3I4hlRE069715; Wed, 17 Apr 2002 23:43:48 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.2/8.12.2/Submit) id g3I4hknS069712; Wed, 17 Apr 2002 23:43:46 -0500 (CDT) Date: Wed, 17 Apr 2002 23:43:46 -0500 From: Dan Nelson To: "Jim C." Cc: Michael E Mercer , Taylor Dondich , questions@FreeBSD.ORG Subject: Re: More of a scripting question I guess. Message-ID: <20020418044346.GB21402@dan.emsphone.com> References: <000901c1e678$bc14fa80$6600a8c0@penguin> <20020418015926.GI72244@dan.emsphone.com> <3CBE2F51.41E19E8A@nc.rr.com> <20020418023400.GJ72244@dan.emsphone.com> <1019106179.72577.32.camel@snafu.concon.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1019106179.72577.32.camel@snafu.concon.homeip.net> User-Agent: Mutt/1.3.28i X-OS: FreeBSD 5.0-CURRENT X-message-flag: Outlook Error Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In the last episode (Apr 18), Jim C. said: > On Wed, 2002-04-17 at 23:34, Dan Nelson wrote: > > In the last episode (Apr 17), Michael E Mercer said: > > > another way to do it is this with the same outcome: > > > > > > while read address ; do > > > somecommand $address > > > done < file.txt > > > > But that puts the input file at the end of the command, which makes it > > harder to see where the input is coming from, especially if you have a > > lot of stuff in your loop. > > But its still more resource intensive. If you pipe a huge file into > while the machine has to store that file into memory before processing > it whereas with the redirection it simply gets filtered straight into > the while loop line by line. No it doesn't; the 'read' command will pull one line at a time out of the pipe. The only extra overhead is the cost of sending your input file through the pipe. If you had done: lines=`cat myfile` for address in $lines ; do mycommand $address done , that does pull the whole input file into memory. -- Dan Nelson dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message