原文:shell脚本报错:"[: =: unary operator expected"

上面脚本执行报错 : : unary operator expected 需要把 pid ne 改为 pid ne 即可 ...

2019-07-01 11:31 0 1636 推荐指数:

查看详情

Shell脚本报错unary operator expected

在匹配字符串时用了类似这样的语句 if[ $timeofday = "yes"]; then echo "Good morning" exit 0 报错的原因是:如果变量timeofday的值为空,那么就if语句就变成了if [ ="yes" ],这不是一个合法 ...

Fri Jul 19 20:07:00 CST 2013 0 37351
shell脚本报错:"[: =: unary operator expected"

shell脚本报错:"[: =: unary operator expected" 在匹配字符串相等时,我用了类似这样的语句: if [ $STATUS == "OK" ]; then echo "OK" fi 在运行时出现了 [: =: unary ...

Thu Jan 24 00:56:00 CST 2019 0 561
shell脚本执行报错[: 0: unary operator expected

在执行shell脚本,if判断语句报错 #!/bin/bash if [ 0 == $testNum ] then echo "Check Result:0" fi    testNum使用时没有定义,无赋值是空(原本是有定义的,只是笔误写错类似tsetNum了),执行 ...

Tue Jul 10 04:34:00 CST 2018 0 7246
[: -ge: unary operator expected 错误

运行报错 : line 5: [: -ge: unary operator expected 错误原因: 由于变量rate初始化赋值为空,那么就成了 [ -ge "10"] 了,显然 [ 和 "10" 不相比较并且缺少了 [ 符号,所以报了这样的错误。 解决办法 ...

Sun Oct 11 02:25:00 CST 2015 0 2092
shell脚本报错退出

shell脚本中,比如有以下的代码: cd /root/test88 rm -rf backup 如果目录/root/test88不存在,脚本不会停止,依然会执行rm -rf backup这个命令 要让脚本停止执行: #!/bin/bash -e 或 set -e ...

Mon Nov 20 20:37:00 CST 2017 0 2142
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM