Should I use quotes to echo multiple words in bash?

Ger*_*ich 2 bash

In shell scripts I usually use echo to print a message. When the message contains multiple words I have to options of how to do that:

# No quotes
echo Hello SO
Run Code Online (Sandbox Code Playgroud)

or

# Quotes
echo 'Hello SO'
Run Code Online (Sandbox Code Playgroud)

Is one way better than the other?

I know that quotes are very important when there are variables, special character, etc. So, this is another question.

Qua*_*odo 7

Echo varies a lot accross implementations, but POSIX does mandate this:

STDOUT
echo 实用程序参数应由单个 <space> 字符分隔,并且 <newline> 字符应跟在最后一个参数之后。

因此,如果您不引用,shell 将完成其工作并在空格上拆分参数,然后 Echo 将输出每个参数,每个参数由一个空格分隔:

$ echo Y X Z
Y X Z
$ echo Y   X   Z
Y X Z
$ echo 'Y   X   Z'
Y   X   Z
Run Code Online (Sandbox Code Playgroud)

当然,整行仍然可以包含特殊标记并且完全失败:

# Variable expansion
$ echo I have $2
I have
Run Code Online (Sandbox Code Playgroud)
# Filename expansion
$ echo hi * there
hi Documents Downloads Music Pictures Videos there
Run Code Online (Sandbox Code Playgroud)
# And other special tokens
$ echo hello (I am I)
bash: syntax error near unexpected token `('
Run Code Online (Sandbox Code Playgroud)

如有疑问,请引用。对于您的特定示例,不,它没有区别。