Re: Script help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2006-10-09 at 13:12 +0100, Dave Mitchell wrote:
> On Mon, Oct 09, 2006 at 12:43:22PM +0100, Dan Track wrote:
> > have a script that does the following:
> > 
> > cat /tmp/file | while read rpm
> > 
> > what I would like to do is to remove the "|" pipe command but keep the
> > "while read rpm" part while also somehow cat the contents of the file
> > into the "while read rpm" line, how can I do that?
> 
>     (
> 	while read rpm; do
> 	    ...
> 	done
>     ) < /tmp/file
> 

actually, the simplest way to do this is:

	while read rpm
	do
		...
	done < /tmp/file

[where you put the do clause makes no difference -- it's just style.]

the parens dave used force the whole thing to be done in a subshell -- a
new process.  if you're doing this once a day, it makes little
difference.  but if you're going to be running this piece of code a
bunch, then extra processes may make a significant difference over time.

john

-- 
cleverly disguised as a responsible adult.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux