在linux下写了一个简单的shell,循环10次.

test.sh

#!/bin/bash
##
##循环10次
##
for ((i=; i<; i++)); do echo Good Morning ,this is $i shell program. done

执行:sh test.sh 报下面的错误.

Syntax error: Bad for loop variable

在网上搜索了一下.

因为Ubuntu为了加快开机速度,用dash代替了传统的bash,所以我们这样执行就没问题.

bash test.sh

那如果我们只想用sh test.sh 这样的方式执行,怎么办呢?

修改一下代码.

for i in `seq `
do echo Good Morning ,this is $i shell program. done

这个时候,你再执行 sh test.sh,就不会报错误啦.

linux shell 报错 Syntax error: Bad for loop variable的更多相关文章

  1. linux shell scripts:Syntax error: Bad for loop variable

    执行脚本报错 #!/bin/bash s=0 for (( i=1; i<=100; i++ )) do s=$(( $s + $i )) done echo $s sh add.sh 报错: ...

  2. shell脚本:Syntax error: Bad for loop variable错误解决方法(转)

    Linux Mint中写了一个简单的shell脚本,利用for..do..done结构计算1+2+3......+100的值,结果执行"sh -n xxx.sh"检测语法时总是报错 ...

  3. 关于报错“syntax error near unexpected token `”和回车换行

    本来是很简单一个事情,转过来是因为打字机这事比较有趣…… http://blog.csdn.net/xyp84/archive/2009/08/11/4435899.aspx 摘要一下: 回车 换行 ...

  4. JS function document.onclick(){}报错Syntax error on token "function", delete this token

    JS function document.onclick(){}报错Syntax error on token "function", delete this token func ...

  5. 一个参数大小写引发的uploadify报错 "Syntax error, unrecognized expression: #"

     上传控件uploadify 报错"Syntax error, unrecognized expression: #" 版本为 uploadify3.2  报错原因:参数ID[hi ...

  6. JS function document.onclick(){}报错Syntax error on token "function", delete this token - CSDN博客

    原文:JS function document.onclick(){}报错Syntax error on token "function", delete this token - ...

  7. adb shell报错:error: insufficient permissions for device的解决办法

    1.错误描述 执行 adb shell 时,报错如下; error: insufficient permissions for device  2.解决办法 1,终端执行 lsusb 结果如下,注意绿 ...

  8. Linux下docker报错syntax error:unexpected protocol at end of statement

    ---恢复内容开始--- [Linux]Shell脚本“syntax error: unexpected end of file”原因及处理 :::https://blog.csdn.net/u013 ...

  9. Shell脚本报错--syntax error near unexpected token for((i=0;i<$length;i++))

    现象: shell脚本使用Nodepad++进行本地编辑,在编辑后上传到linux机器进行执行时提示“syntax error near unexpected token for((i=0;i< ...

随机推荐

  1. SVN中(trunk tags branches)的使用理解

    trunk--主干(永远都是最新的,每发布一个版本会在tags和branches上进行分支) tags-标签(只读,用于存放发布后的文件冻结,以及对应发布后版本的源文件:可以是来自主干或者分支的发布: ...

  2. CruiseControl.NET配置文件(生产环境版本,与SVN结合自动部署)

    配置如下: 说明:此配置文件的功能是当有SVN修改时,会自动触发并编译发布,间隔为10秒. 由于配置文件上面有注释,如果提示节点配置错误,请删除这些注释. 官方详细节点配置说明:http://www. ...

  3. ueditor的优酷插件模式开发,目前开发了腾讯视频转换插件

    项目相关地址 源码:https://github.com/easonjim/ueditor_plugin bug提交:https://github.com/easonjim/ueditor_plugi ...

  4. mplayer依赖关系不满足

    mplayer以及其他fork出来的如mplayer2是命令行下的媒体播放器.一般ubuntu等的桌面系统都自带.然而自己使用了一段时间后突然出现缺少库文件,各种依赖关系不满足也未能重新安装.为了以后 ...

  5. SPOJ GSS3 Can you answer these queries III

    Time Limit: 330MS   Memory Limit: 1572864KB   64bit IO Format: %lld & %llu Description You are g ...

  6. shell命令xargs

    今天准备找出nginx非空的日志并压缩成一个文件 find . -name "meta.access.log.*" -type f -size +0k | tar -cjv -f ...

  7. js实现A*寻路算法

    这两天在做百度前端技术学院的题目,其中有涉及到寻路相关的,于是就找来相关博客进行阅读. 看了Create Chen写的理解A*寻路算法具体过程之后,我很快就理解A*算法的原理.不得不说作者写的很好,通 ...

  8. POJ 2796 Feel Good(单调栈)

    传送门 Description Bill is developing a new mathematical theory for human emotions. His recent investig ...

  9. Mysql 列转行统计查询 、行转列统计查询

      -- ---------------------------- -- Table structure for `TabName` -- ---------------------------- D ...

  10. 用css3实现各种图标效果(1)

    公共样式 应该说现在绝大多数公司的项目前端都是一团乱,不仅仅是js写的没有任何框架而言,css同样也是如此,导致项目如果要升级或者说有新的变更维护起来就特别困难. 最近领导决定花大时间整理一下css样 ...