"Alfred M. Szmidt" <[EMAIL PROTECTED]> writes: > Could someone explain the following behaviour for me? Because I sure > do not understand it.
This has nothing to do with echo and everything to do with the shell. > [EMAIL PROTECTED]:/tmp/foo$ touch 1 2 3 4 5 > [EMAIL PROTECTED]:/tmp/foo$ foo=`ls` The value of foo now contains a bunch of newlines, among others. > [EMAIL PROTECTED]:/tmp/foo$ /bin/echo $foo > 1 2 3 4 5 Unquoted variable substitution splits on whitespace and /bin/echo receives 5 arguments, each of which is echoed separated by a single space. This is equivalent to: $ /bin/echo 1 2 3 4 5 > [EMAIL PROTECTED]:/tmp/foo$ /bin/echo "$foo" > 1 > 2 > 3 > 4 > 5 Quoted variable substitution does not split and preserves all whitespace as is. The (single) argument is echoed unchanged. This is equivalent to: $ /bin/echo "1 2 3 4 5" > [EMAIL PROTECTED]:/tmp/foo$ foo='1 2 3 4 5' Now foo contains a completely different value. > [EMAIL PROTECTED]:/tmp/foo$ /bin/echo $foo > 1 2 3 4 5 Still splitting on whitespace, still passing 5 arguments, same as first example above. > [EMAIL PROTECTED]:/tmp/foo$ /bin/echo "$foo" > 1 2 3 4 5 Still no splitting, still passing one argument. This is equivalent to: $ /bin/echo "1 2 3 4 5" Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-coreutils