/bin/bash, what is the difference between the following two cases:
- echo $IFS
- echo "$IFS"
I observe different outputs.
"$IFS" will be a single argument. The function of the
"" is that it bounds the spaces in them into a single word, with spaces.
For example, if IFS contains
a__b (imagine spaces instead of the
echo "$IFS" will be after the variable substutition:
echo "a b", thus the
echo command will get a single argument. Thus, it will print:
echo $IFS will be substituted to
echo a b, which will mean, that
echo gets two arguments: an
a and a
b. So, it will print:
There are other differences as well, for example if IFS contains an enter, it will be also hidden in the first version, but not in the second.