为什么在将 shell 分配给变量时,字符串中的空格会被剪掉?

Why are white spaces in a string trimmed in shell when it is assigned to a variable?

我正在分配一个字符串 (my name is xxxxxx ssddd) 一个 shell 变量 (str)
当回显变量时。

echo $str  
my name is xxxxxx ssddd  

为什么不考虑空格?

引用您的字符串以保留白色 space:

a="four    spaces"
echo $a
four spaces


echo "$a"
four    spaces

但是,当将一个变量赋值给另一个变量时,白色space也会被保留:

a=$b
echo "$b"
four    spaces