Re: Shell Scripting Question
Hello,
I believe something like this should work:
for $fruit in 'cat /usr/food/fruits.txt' &&
do echo -n $fruit
done
echo -n omits the trailing newline as seen in 'man echo'
Enjoy,
Cameron Matheson
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.
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Reply to: