By quoting you force it to be one word, no word-splitting takes place.
Differerent quoting styles:
Code:
'ls -l'
"ls -l"
ls\ -l
The shell invokes a one-word command with an embedded space.
The same applies to the command arguments:
Code:
touch "two words"
ls -l 'two words'
rm two\ words
The shell recognizes the one-word argument, dequotes it, and hands it to the respective command (first word).
is a concatenation of many '' strings, like ''+'ls'+''<space>''+'-l'+''
The word-splitting is according to $IFS (Input Field Separators).
With IFS=$'\n\t' the space is removed but the \t (tab) is still there. Then
is one word, but
is two words.
What happens with the \n (newline)? On the command line (actually readline, also read) a newline causes an end-of-input-line so it won't exist for a direct word-splitting.
But the following example demonstrates it:
Code:
twolines="line1
line2"
echo "with word-splitting"
echo $twolines
echo 'double quotes "" allow $-evaluation/substitution but not word-splitting:'
echo "$twolines"
Instead of
echo ...
you better use
printf "<%s>\n" ...
for clarity; the format is applied on each argument (wrapped in < > followed by a newline).