之前在写脚本时遇到了这样的错误
“[: ==: unary operator expected”
这是由于做判断的变量值为空导致的。
谷歌出解决方案:
在变量之后加任意字符。例如,要判断变量un是否为auto又要防止un为空出错则这样写
if [ ${un}x == autox]
当un为auto时,表达式为autox == autox,成立;
un为空,表达式为x == autox ,则不成立。

[: ==: unary operator expected 解决方法的更多相关文章

  1. shell报错:-bash: [: ==: 期待一元表达式 解决方法 ([: ==: unary operator expected)

    shell报错:-bash: [: ==: 期待一元表达式 解决方法 ([: ==: unary operator expected) blogdaren 2015-02-26  抢沙发 14916人 ...

  2. shell脚本报错:"[: =: unary operator expected"

    shell脚本报错:"[: =: unary operator expected" 在匹配字符串相等时,我用了类似这样的语句: if [ $STATUS == "OK&q ...

  3. unary operator expected

    在centos系统从root用户切换到oracle用的时候,总是提示 : -bash- : :[: unary operator expected 能切换成功,就是总提示上面这个, 后来找到原因,在安 ...

  4. bullet, iOS真机编译错误error: identifier or immediate expression expected解决方法

    刚才发现c3dEngine2(http://git.oschina.net/wantnon2/c3dEngine2 或 https://github.com/wantnon2/c3dEngine2)的 ...

  5. Shell脚本报错unary operator expected

    在匹配字符串时用了类似这样的语句 if[ $timeofday = "yes"]; then echo "Good morning" exit 0 报错的原因是 ...

  6. python中IndentationError: expected an indented block错误的解决方法

    IndentationError: expected an indented block 翻译为IndentationError:预期的缩进块 解决方法:有冒号的下一行要缩进,该缩进就缩进

  7. 编绎报错,解决方法objc_msgSend too many arguments to function call,expected 0, have3 (转)

      编绎报错,objc_msgSend too many arguments to function call,expected 0, have3 解决方法:    

  8. Bean named '...' is expected to be of type [...] but was actually of type [com.sun.proxy.$Proxy7解决方法

    报错 三月 07, 2017 8:09:52 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepare ...

  9. TypeError: expected string or buffer的解决方法

    错误种类:TypeError: expected string or buffer 具体错误解释:这是因为返回的变量不是字符类型,而导致此错误 具体解决方法:在具体程序段前加if判断语句,判断程序返回 ...

随机推荐

  1. 【块状树】【博弈论】bzoj3729 Gty的游戏

    块状树,每个块的根记录一下当前块内距块根为奇数距离的异或和和偶数距离的异或和,询问的时候讨论一下即可. 总的节点数可能超过50000. #include<cstdio> #include& ...

  2. 【暴力】bzoj3713 [PA2014]Iloczyn

    没什么好说的. #include<cstdio> using namespace std; typedef long long ll; ]; int main() { scanf(]=; ...

  3. [CodeChef-DGTCNT]Chef and Digits

    题目大意: 若一个十进制数$x$(不含前导零)满足数码$i$恰好出现$t_i$次,则这个数是坏的,否则是好的.求区间$[L,R](1\le L,R\le10^{18})$中有多少好数. 思路: 显然可 ...

  4. 【R笔记】R语言利器之ddply

    ddply()函数位于plyr包,用于对data.frame进行分组统计,与tapply有些类似 准备数据 # 使用stringsAsFactors=F来防止data.frame把向量转为factor ...

  5. 动态RIP配置路由表

    动态RIP配置路由表 以Router11为例子: (1)配置端口ip(两个端口需要设置两个ip) Router(config)#inter f0/0 Router(config-if)#ip add ...

  6. linux-内存使用-free

    解释一下Linux上free命令的输出. 下面是free的运行结果,一共有4行.为了方便说明,我加上了列号.这样可以把free的输出看成一个二维数组FO(Free Output).例如: FO[2][ ...

  7. NDK 调用对象属性

    JNIEXPORT jbyteArrayJNICALL Java_com_lanhetech_iso8583_nativeLib_Iso8583NativeLib_pubPack8583 (JNIEn ...

  8. C# 6.0可能会支持模式匹配了

    今天在CodePlex的Roslyn讨论区发现了一个帖子:Draft spec for records and pattern-matching in C#,估计MS计划在C# 6.0中支持模式匹配了 ...

  9. jQuery--样式

    Jquery(一)——样式篇1.$(document).ready 的作用是等页面的文档(document)中的节点都加载完毕后,再执行后续的代码, 因为我们在执行代码的时候,可能会依赖页面的某一个元 ...

  10. C# 7 新特性-1

    来源https://www.kenneth-truyers.net/2016/01/20/new-features-in-c-sharp-7/ Tuples What Tuples是数据的临时分组.区 ...