Greg Wooledge a écrit : > On Wed, Aug 26, 2009 at 03:04:16PM -0400, Sam Steingold wrote: >> foo=`ls` >> echo $foo > > echo "$foo"
What Greg did not explicitly said: 95% of the time you write $foo unquoted, you are wrong and should have written double-quoted "$foo" instead. This not just about newlines. See "A Guide to Unix Shell Quoting" for details: http://www.mpi-inf.mpg.de/~uwe/lehre/unixffb/quoting-guide.html Another better practice is to use printf, since $foo could start with a minus sign: printf '%s' "$foo"