On Friday 18 April 2008 14:02, Dave Rutherford wrote: > Quotes or escapes in the output of the `` are input to the shell rather > than shell syntax, so won't be interpreted. You just need to quote more. > > $ foo () { echo sony; echo apple; echo hewlett packard; } > > Now note the difference between: > > $ for w in "`foo`"; do echo $w; done > sony apple hewlett packard
This assigns "sony", "apple", "hewlett" and "packard" to $w. > $ for w in `foo`; do echo "$w"; done > sony > apple > hewlett > packard Same as above, but $w is quoted (which does not change anything in this case). > $ for w in "`foo`"; do echo "$w"; done > sony > apple > hewlett packard This assigns "sony apple hewlett packard" as a single value to $w. Note that the for loop is executed only once. This is not what the OP wanted.