如何在UNIX中使用if statment

Hel*_*rld 1 unix linux shell

我试图执行以下命令.

de="hello world"
if [ $de -eq "hi" ]; then
....
....
Run Code Online (Sandbox Code Playgroud)

因为你好和世界之间的空间,它出错了.但如果我定义de ="helloworld"它就可以了.你有没有办法告诉我,如果有一个句子中有空格的陈述,我是否可以使用它?

nos*_*nos 5

引用变量名称,

de="hello world"
if [ "$de" = "hi" ]; then
Run Code Online (Sandbox Code Playgroud)

-eq用于比较数字,因此使用=表示文本.请参阅此处,了解如何在bash中进行各种比较.