Bash scripting and while loop piping

davidbrit2

Licensed Computer Geek
How can I send the output of a command to a while loop. I can do so with a file doing this:

while command
do
something
done < /tmp/foo
 
Is this what you are looking for:

Code:
cat /etc/hosts | while read foo; do echo $foo; done

Brian
 
Hmm, I could have sworn I tried something like that, but maybe I'll play around with that setup again.
 
Back
Top