linux 脚本 提示 -bash: [: ==: unary operator expected 解决办法
2014-08-07 13:55
411 查看
函数脚本 func.sh
source func.sh
plus 12 13
输出25
但是执行 plus 12
输出
-bash: [: ==: unary operator expected
解决办法 []改为 [[ ]]
但是 这种方式 有时会出现无法判读的错误 ,
#!/bin/bash #定义变量 plus(){ if [ $2 == '' ]; then echo "please" else echo $[$1 + $2] fi }
source func.sh
plus 12 13
输出25
但是执行 plus 12
输出
-bash: [: ==: unary operator expected
解决办法 []改为 [[ ]]
if [[ $2 == '' ]]; then
但是 这种方式 有时会出现无法判读的错误 ,
if [ $2 -eq '' ]; then才是合适的解决方式
相关文章推荐
- Linux终端执行shell脚本,提示权限不够的解决办法
- Linux运行shell脚本提示No such file or directory错误的解决办法
- Linux运行脚本命令提示No such file or directory错误的解决办法
- 【Linux】Linux下输入ifconfig提示bash: ifconfig: command not found解决办法
- shell脚本执行后出现错误提示" /bin/bash^M: bad interpreter: No such file or dire"的解决办法
- Linux终端执行shell脚本,提示权限不够的解决办法
- Linux执行shell脚本提示文件找不到问题解决办法
- linux下,su用户时,出现提示:-bash: fork: retry: Resource temporarily unavailable的解决办法
- linux下执行脚本,提示Command not found解决办法
- VNC远程桌面到linux,提示connection refused(10061)解决办法
- linux cp提示覆盖确认的解决办法
- linux 启动脚本以及解决chkconfig的办法
- 进入LINUX后显示-bash-3.2的解决办法
- linux新建用户在命令行下使用tag没有提示解决办法
- linux使用su切换用户提示 Authentication failure的解决办法
- Linux中cp总是提示覆盖文件的解决办法
- linux 安装 VTK 提示libvtkNetCDF_cxx.so: cannot open shared object file: No such file or directory 的解决办法
- 【转】使用ASP.NET或HTML时,浏览器(如IE7)提示“此网站使用脚本窗口向您索取信息”解决办法
- Linux 运行bin文件,提示 权限不够的解决办法
- Linux提示no crontab for root的解决办法