之前在写脚本时遇到了这样的错误
“[: ==: 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. 【可持久化Trie】模板

    总算找到个能看懂的了,orz Lavender. #define INF 2147483647 #define N 100001 #define MAXBIT 31 int root[N],ch[N* ...

  2. IO流--字符流缓冲技术

    缓冲技术是为了提高数据的读写效率而提出的. (1)字符流的缓冲读 在字符流的缓冲技术中提供了一个newLine()方法,这个方法是跨平台的 在读数据的时候采用读完直接刷新的方式可以保证断电后数据不会丢 ...

  3. jquery获取css颜色值返回RGB应用

    我来给大家介绍一下在jquery获取css颜色值返回RGB方法,希望此文章对各位同学会有所帮助哦.   代码如下:  代码如下 复制代码 a, a:link, a:visited { color:#4 ...

  4. 如何订阅Linux相关的邮件列表

    转:http://blog.163.com/sunshine_linting/blog/static/44893323201282114012845/ 1.google"linux kern ...

  5. CSS3:animation动画

    animation只应用在页面上已存在的DOM元素上,学这个不得不学keyframes,我们把他叫做“关键帧”. keyframes的语法法则: @keyframes flash { from{ le ...

  6. 【JUnit4.10源码分析】6.1 排序和过滤

    abstract class ParentRunner<T> extends Runner implements Filterable,Sortable 本节介绍排序和过滤. (尽管JUn ...

  7. Linux FTP配置

    Linux下实现ftp的软件有很多,最常见的有vsftpd,Wu-ftpd和proftp等.访问ftp服务器时需要验证,只有经过了ftp服务器的验证用户才能访问和传输文件.这里我们用vsftpd,vs ...

  8. oracle 10g函数大全--转换函数

    chartorowid(c1) [功能]转换varchar2类型为rowid值 [参数]c1,字符串,长度为18的字符串,字符串必须符合rowid格式 [返回]返回rowid值 [示例] SELECT ...

  9. ISP图像调试工程师——边缘增强(熟悉图像预处理和后处理技术)

    http://blog.csdn.net/u013033431/article/details/50907907 http://dsqiu.iteye.com/blog/1638589 概念: 图像增 ...

  10. EL表达式介绍(1)

    1. 产生背景: 在MVC体系结构中,JSP页面只是用来显示数据,但JSP脚本中的表达式功能不够强大,它不能直接对隐式对象中某对象的属性进行显示,需要配合 scriptlet才能显示数据,很是麻烦,如 ...