Re: OT: shell scripting problem

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

 



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@xxxxxxxxxxxxxxxxxxxxxxx  Z1aaaaaaa@xxxxxxxxxxxxxxxxxxxxxxx
Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/


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

  Powered by Linux