Hi, (I am not programmer) On Sat, Oct 27, 2001 at 06:10:35PM -0400, Sunny Dubey wrote: > 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.
Bash: Use read and IFS IFS The Internal Field Separator that is used for word splitting after expansion and to split lines into words with the read builtin command. The default value is ``<space><tab><newline>''. -- ~\^o^/~~~ ~\^.^/~~~ ~\^*^/~~~ ~\^_^/~~~ ~\^+^/~~~ ~\^:^/~~~ ~\^v^/~~~ + Osamu Aoki <[EMAIL PROTECTED]>, GnuPG-key: 1024D/D5DE453D + + My debian quick-reference, http://www.aokiconsulting.com/quick/ +