【转】bash中的错误 too many arguments
来源:互联网 发布:java程序员简历项目 编辑:程序博客网 时间:2024/06/05 06:53
来源:http://www.hao32.com/unix-linux/394.html
我之前为了判断一个文件的内容是不是为空,使用如下语句:
if test -z `cat filename`
当filename为空或者只有一行没有空格的字符串的时候,一切正常,反之,则会报,诸如
: too many arguments,甚至是: binary operator expected之类的错误,参见了一下:http://www.ibm.com/developerworks/cn/linux/shell/bash/bash-2/index.html
filename中的空格回车等迷惑了bash
如果环境变量没放在双引号中,那么bash 认为条件中的自变量过多。可以用双引号将字符串自变量括起来消除该问题。请记住,养成将所有字符串自变量用双引号括起的习惯,将除去很多类似的编程错误。
本文问题解决方法很简单,给命令执行部分加上双引号就可以了:
if test -z "`cat filename`"
- 【转】bash中的错误 too many arguments
- 关于Shell 脚本中的"[: too many arguments"错误
- Too many arguments error in bash
- Git: bash: cd: too many arguments
- linux bash中too many arguments问题的解决方法
- Too many input arguments.
- shell [: too many arguments
- Too many input arguments.
- too many positional arguments
- 编译错误“Too many arguments to function call....”
- Too many arguments to function call错误解决方案
- 消息机制Too many arguments to function call错误
- 错误:Too many arguments to function call,expected 0,have *
- shell test(too many arguments)
- Linux中的错误:too many open files
- Linux中的错误:too many open files
- Xcode6环境下AQGridView编译错误:'too many arguments to function call, expected 0, have 4'
- too many arguments to function call, expected 0, have 3 错误‘解决办法
- mysql优化常识
- metasploit-学习4---windows 7下的安装
- 技术是为了效益
- 转载自博客园的一篇文章 通过SQL Server Profiler来监视分析死锁
- 申请google map key
- 【转】bash中的错误 too many arguments
- HTTP协议详解
- 第三周工作小结
- 苹果谷歌冰火两重天:中国境遇大不同
- 用split和cat分割和恢复文件
- 30岁那年,我经历了太多,太多。
- 两种实现Toast 的例子(图片&文字)
- Painted Skin
- dereferencing pointer to incomplete type错误