目前我的整个脚本是这样的:
#!/bin/sh
clear;
blanko="";
# Dummy-Variablen
variable=Testvariable;
if [[$variable == $blanko]];
then
echo "Nichts da!"
else
echo $variable
fi
如果我输入
TestSelect.sh
我明白了
/usr/bin/TestSelect.sh: line 6: [[Testvariable: command not found
Testvariable
我该如何解决这个问题?
最佳答案
这是个问题:
if [[$variable == $blanko]];
方括号内需要空格,这样使用:
[[ "$variable" == "$blanko" ]] && echo "Nichts da!" || echo "$variable"
关于string - 在 Bash 中比较两个字符串时出现 "command not found"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19733437/