我正在使用 SH shell,我正在尝试将字符串与变量的值进行比较,但if
条件始终执行为真。为什么?
这是一些代码:
Sourcesystem="ABC"
if [ "$Sourcesystem" -eq 'XYZ' ]; then
echo "Sourcesystem Matched"
else
echo "Sourcesystem is NOT Matched $Sourcesystem"
fi;
echo Sourcesystem Value is $Sourcesystem ;
即使这样也行不通:
Sourcesystem="ABC"
if [ 'XYZ' -eq "$Sourcesystem" ]; then
echo "Sourcesystem Matched"
else
echo "Sourcesystem is NOT Matched $Sourcesystem"
fi;
echo Sourcesystem Value is $Sourcesystem ;
其次,我们可以将其与 NULL 或空字符串匹配吗?