In bash on Mac OSX, I have a file (test case) that contains the lines
x xx xxx
xxx xx x
But when I execute the command
for i in `cat r.txt`; do echo "$i"; done
the result is not
x xx xxx
xxx xx x
as I want but rather
x
xx
xxx
xxx
xx
x
How do I make echo give me ‘x xx xxx’?
By default, a Bash for loop splits on all whitespace. You can override that by setting the
IFSvariable: