shell 编程 错误 bash: [: missing `]'
2016-11-15 14:46
357 查看
问题的解决
正如上面所说,前两次运行都没有问题,那么细细分析代码,发现,程序执行到这里:
if [ "$HEADER" = "true"] ;then
出现了问题 ,这是因为 在 [ ] 内 要有空格 ,也就是说 "$HEADER" 前 和 "true" 后要有空格才行。
所以必须改为
if [ "$HEADER" = "true" ] ;then
这样就解决了 bash: [: missing `]'
转载自http://blog.csdn.net/longxibendi/article/details/5886396
正如上面所说,前两次运行都没有问题,那么细细分析代码,发现,程序执行到这里:
if [ "$HEADER" = "true"] ;then
出现了问题 ,这是因为 在 [ ] 内 要有空格 ,也就是说 "$HEADER" 前 和 "true" 后要有空格才行。
所以必须改为
if [ "$HEADER" = "true" ] ;then
这样就解决了 bash: [: missing `]'
转载自http://blog.csdn.net/longxibendi/article/details/5886396
相关文章推荐
- 解决 shell 编程 错误 bash: [: missing `]'
- Linux编程环境介绍(2) -- shell(Bash) 介绍
- 使用FUNCNAME 和BASH_LINENO实现shell脚本中定位函数错误在代码中的位置
- Linux Bash Shell高级重定向操作--深入了解标准错误输出和标准输出
- Bash Pitfalls: 编程易犯的错误
- Bash Shell脚本编程-变量知识
- Bash shell常见错误
- shell脚本执行错误:#!/bin/bash: No such file or directory
- bash shell基础编程
- Bash 实例,第 1 部分:Bourne again shell (bash) 基本编程
- 8.17_Linux之bash shell脚本编程入门篇(三)之循环以及函数function的使用
- bash shell:重定向标准错误输出
- 云计算免费视频教程:Bashshell脚本编程详解
- Shell脚本编程概述(四):bash内置字符处理工具
- Bash 实例,第一部分Bourne again shell (bash) 基本编程
- 运行shell脚本,错误:-bash: ./xxx.sh: /bin/bash^M: bad interpreter: No such file or directory
- Bash 实例,第一部分 Bourne again shell (bash) 基本编程
- Shell 编程:Bash空格的那点事
- Linux--Shell 编程-bash,命令替换,if分支嵌套,运算,输入输出
- centos shell基础 alias 变量单引号 双引号 history 错误重定向 2>&1 jobs 环境变量 .bash_history source配置文件 nohup & 后台运行 cut,sort,wc ,uniq ,tee ,tr ,split, paste cat> 2.txt <<EOF 通配符 glob模式 发邮件命令mail 2015-4-8 第十二节课