OT: shell scripting problem

John Summerfied debian at herakles.homelinux.org
Thu May 19 06:45:40 UTC 2005


Steven W. Orr wrote:

> =>
> =>I have another solution.  Change the script (let's call it "fred"):
> =>
> =>	while read i; do
> =>	    myscript.sh $i
> =>	done
> =>
> =>Then "cat textfile | ./fred" would accomplish the same thing.
> 
> Why in the Wide World of Sports do people do stuff like that?
> 
> ./fred < textfile
> 
> No pipe, no extra process, no fuss.

_I_ often find myself backing up and changing the cat to a grep.

Also, "cat textfile" can be used to represent a generic data source.

Imagine this function
function datasource ()
{
cat textfile
}

then it could be used as
datasource | ./fred

The function datasource could be replaced (see the dhcp client scripts 
for an example where one might choose to do this) to obtain the data 
from another source - and SQL database as I've been doing recently, or 
to do some more complicated preprocessing of the data.





-- 

Cheers
John

-- spambait
1aaaaaaa at computerdatasafe.com.au  Z1aaaaaaa at computerdatasafe.com.au
Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/




More information about the fedora-list mailing list