Alfred M. Szmidt wrote: > Could someone explain the following behaviour for me? Because I sure > do not understand it.
You will be slapping your forehead as soon as you realize what is happening. This is normal behavior of the shell passing and processing arguments. > [EMAIL PROTECTED]:/tmp/foo$ touch 1 2 3 4 5 > [EMAIL PROTECTED]:/tmp/foo$ foo=`ls` Since the output of ls is not a tty the -1 option is implied and ls will list each file one per line. Piped to 'wc -c' you would count 10 characters, five for the number and five for the newlines. Piping to 'od -c' would show them character by character. > [EMAIL PROTECTED]:/tmp/foo$ /bin/echo $foo > 1 2 3 4 5 The shell's input field separator (IFS) is space, tab, and newline. The shell's pass over the command line before argument splitting expands the value of the variable. The newlines separating the filenames cause the the shell to split this into five arguments. > [EMAIL PROTECTED]:/tmp/foo$ /bin/echo "$foo" > 1 > 2 > 3 > 4 > 5 With double quotes the newline is now part of the echo argument. There is only one argument to echo. The newlines are now part of the string. > [EMAIL PROTECTED]:/tmp/foo$ foo='1 2 3 4 5' > [EMAIL PROTECTED]:/tmp/foo$ /bin/echo $foo > 1 2 3 4 5 > [EMAIL PROTECTED]:/tmp/foo$ /bin/echo "$foo" > 1 2 3 4 5 > [EMAIL PROTECTED]:/tmp/foo$ /bin/echo --version > echo (GNU coreutils) 5.2.1 Bob _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-coreutils