on Sat, Oct 27, 2001 at 06:10:35PM -0400, Sunny Dubey ([EMAIL PROTECTED]) wrote: > (sorry if this got send to the list twice) > > Hi, > > I have a file which as a list of varions itmes (example below) > > # /usr/food/fruits.txt > banana medium yellow > apple small red > watermelon big green > plum small red > etc etc etc ... > > when I create the following loop ... > > for $fruit in `cat /usr/food/fruits.txt` && > do echo $fruit > some code with $fruit && > some more code with $fruit && > done > > it prints the list, but with each word on a seperate line (as followed) > > banana > medium > yellow > apple > etc etc etc ... > > my question is, how do I get it to print the list with each line as the > variable $fruit, as opposed to $fruit being each word.
Try 'read' instead. man bash for more info.
cat /usr/food/fruits.txt |
while read fruit
do
echo $fruit
done
Peace.
--
Karsten M. Self <[email protected]> http://kmself.home.netcom.com/
What part of "Gestalt" don't you understand? Home of the brave
http://gestalt-system.sourceforge.net/ Land of the free
Free Dmitry! Boycott Adobe! Repeal the DMCA! http://www.freesklyarov.org
Geek for Hire http://kmself.home.netcom.com/resume.html
pgpgMGLe9tSKi.pgp
Description: PGP signature

