I have a text file that contains something like this:
abc 123, comma
the quick brown fox
jumped over the lazy dog
comma, comma
I wrote a script
for i in `cat file`
do
echo $i
done
For some reason, the output of the script doesn't output the file line by line but breaks it off at the commas, as well as the newline. Why is cat or "for blah in cat xyz
" doing this and how can I make it NOT do this? I know I can use a
while read line
do
blah balh blah
done < file
but I want to know why cat or the "for blah in" is doing this to further my understanding of unix commands. Cat's man page didn't help me and looking at for or looping in the bash manual didn't yield any answers (http://www.gnu.org/software/bash/manual/bashref.html). Thanks in advance for your help.