shell中如何比较 路径 字符串?
比如A字符串:/users/ricky/0220/app1
我获取了另外一个路径字符串B,如何比较A B 是否相同?
if [[ "$A" -eq "$B" ]];then
echo "same path"
else
echo "diff path"
fi
报错: arithmetic syntax error, 应该是路径中有特殊字符/的原因,各位有什么好办法吗?
------解决方案--------------------Perl code
A="/users/ricky/0220/app1";B="/users/ricky/0220/app1";if [[ "$A" == "$B" ]];then echo "same path"; else echo "diff path"; fi
------解决方案--------------------
字符串比较用=即可,数字才用-eq