每次我运行我的脚本时,下面的 if 语句都会给我错误;
script.sh: [Error==Error]: not found
Run Code Online (Sandbox Code Playgroud)
或者
script.sh: [Error==-2]: not found
Run Code Online (Sandbox Code Playgroud)
if ["$P1"=="$P2"];then
echo $name
fi
Run Code Online (Sandbox Code Playgroud)
我试过其他版本
if ["$P1"=="$P2"]
then
echo $name
fi
Run Code Online (Sandbox Code Playgroud)
和
if [[ "$P1" == "$P2" ]]
then
echo $name
fi
P1="Error"
P2="$(sed -n '1p' somefile.txt)"
Run Code Online (Sandbox Code Playgroud)
somefile.txt 可能包含数字或字符串
bash ×1