在判断语句中如果遇到变量字符串太长,就会遇到这种提示;
把变量加上双引号即可避免

shell脚本binary operator expected错误
发表于142 天前  ⁄ BashShell  ⁄ 暂无评论 ⁄ 被围观 933 次+
今天写了个shell脚本一运行就出现"binary operator expected"错误
test1.sh: line 6: [: /export/p_w_picpaths/a10091400ux0415: binary operator expected
检查脚本第六行:
if [ ! -f /export/p_w_picpaths/$line ];then
上网查了一下,加上双引号,就可以了
将 if [ ! -f /export/p_w_picpaths/$line ];then 改为
if [ ! -f "/export/p_w_picpaths/$line" ];then
问题解决.