From owner-freebsd-questions Thu Apr 18 16:37: 5 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mail5.carolina.rr.com (fe5.southeast.rr.com [24.93.67.52]) by hub.freebsd.org (Postfix) with ESMTP id 339D837B417 for ; Thu, 18 Apr 2002 16:36:59 -0700 (PDT) Received: from [192.168.100.13] ([66.57.159.198]) by mail5.carolina.rr.com with Microsoft SMTPSVC(5.5.1877.687.68); Thu, 18 Apr 2002 18:34:33 -0400 Subject: Re: More of a scripting question I guess. From: "Jim C." Reply-To: jconner@enterit.com To: Dan Nelson Cc: "Jim C." , Michael E Mercer , Taylor Dondich , questions@FreeBSD.ORG In-Reply-To: <20020418151102.GC21402@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> <20020418044346.GB21402@dan.emsphone <20020418151102.GC21402@dan.emsphone.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.3 Date: 18 Apr 2002 19:57:09 -0300 Message-Id: <1019170630.72577.94.camel@snafu.concon.homeip.net> Mime-Version: 1.0 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 On Thu, 2002-04-18 at 12:11, Dan Nelson wrote: > In the last episode (Apr 18), Jim C. said: > > On Thu, 2002-04-18 at 01:43, Dan Nelson wrote: > > > 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; > > > > It does. (not significantly but it does) > > > > > the 'read' command will pull one line at a time out of the pipe. > > > > Correct. However, the pipe "fills up" before read starts to take lines > > out of it. This is where the resources get taken. > > Pipes aren't infinite buffers. The pipe fills up at 16k, and simply > blocks cat until the script empties it a bit. The resources are taken > by the extra syscalls and the context switches between the shell and > cat. > > > Based on these tests I guarantee you the pipe is taking more system > > resources (albeit not much) than the redirect is. > > No argument there. But I'd have switched to C long before trying to > process a 15MB file line-by-line in a scripting language :) > hahaha...yes. I suppose so that would have been the best route to go in such a situation. > I think we've strayed into bikeshed territory anyhow. indeed. =P - Jim > > -- > Dan Nelson > dnelson@allantgroup.com > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message