我正在尝试比较字符串。我收到“找不到命令”错误。如何比较字符串?
代码:
#!/bin/bash
STR="Hello World"
if [$STR="Hello World"]; then
echo "passed test"
else
echo "didn't pass test"
fi
输出:
test.sh: line 4: [Hello: command not found
didn't pass test
我正在尝试比较字符串。我收到“找不到命令”错误。如何比较字符串?
代码:
#!/bin/bash
STR="Hello World"
if [$STR="Hello World"]; then
echo "passed test"
else
echo "didn't pass test"
fi
输出:
test.sh: line 4: [Hello: command not found
didn't pass test