(转) 一个从fedora7中拷贝过来的bash脚本,居然不能在ubuntu下面执行,提示错误 Bad for loop variable G了一把,在TW同胞那里找到了答案~原来是bash和dash的问题 解决方法: 使用 sudo dpkg-reconfigure dash 选择NO。。 世界又清静了~(经典!) 感谢link:http://hi.baidu.com/yk103/blog/item/1e9831fa3fc23d...
错误如下: Syntax error: Bad for loop variable 分析: 从 ubuntu 6.10 开始,ubuntu 就将先前默认的bash shell 更换成了dash shell;其表现为 /bin/sh 链接倒了/bin/dash而不是传统的/bin/bash。 allen@allen-lql ~/workspace/script $ ls -l /bin/sh lrwxrwxrwx 1 root root 4 Aug 12 14:29 /bin/...
常用到的循环有for循环和while循环。下面就分别介绍一下两种循环的结构。【for循环】:Shell脚本中的for循环示例:#! /bin/bash ## author:Xiong Xuehao ## Use for in this script. for i in `seq 1 5`; do echo $i done脚本中的 shell脚本循环执行mysql 删除 for循环 bash while循环 转载 IT独行侠 ...
Shell 脚本(shell script),是一种为 shell 编写的脚本程序。 业界所说的 shell 通常都是指 shell 脚本,但读者朋友要知道,shell 和 shell script 是两个不同的概念。 由于习惯的原因,简洁起见,本文出现的 "shell编程" 都是指 shell 脚本编程,不是指开发 shell 自身。 Shell 环境 Shell 编程跟 JavaScript、php...
1.bash -n 方式调试 bash -n script 这种方式读取shell脚本,但不实际执行, 用于测试Shell脚本中是否存在语法错误 2.使用-x参数调试:通过执行脚本时加 -x,可以使得脚本在执行时显示每一行命令及其参数。这种方法简单而实用,适用于小规模的调试任务。例子test2.sh脚本:#!/bin/bashname="John"age=30echo"...
[root@www shell-script]# cat c_for02.sh#!/bin/bashfor((i=1,j=100;i<=10;i++,j--))doecho"i=$ij=$j"done 1. 2. 3. 4. 5. 6. for的无限循环 #!/bin/bashfor((i=0;i<1;i+=0))doecho"infinite loop"done 1. 2.
Shell script 是解释型语言,而不是编译型语言shell 分好多种,如果想看你的操作系统中支持哪几种,可以执行如下命令: cat /etc/shells 输出如下(每个人的不一样): # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using ...
shell编程:for循环 - trafalgar999 - 博客园[2] 前言 最近忽然发现,自己shell 中的循环,似乎除了while read id以外,忘得一干二净了。 1-for循环 鼎鼎有名的for,自然是每种语言都不可或缺的。 在shell 中,存在两种风格的for 语句。 第一种: 代码语言:javascript ...
for skill in Ada Coffe Action Java; do echo "I am good at ${skill}Script" done #只读变量/bin/sh: NAME: This variable is read only. 也不能删除 url="https://www.google.com" readonly url url="https://www.runoob.com" # 删除变量 unset name ``` ...
如果用sh执行 *.sh,for的这一句式是无法执行的,会报错“Syntax error: Bad for loop variable”。 后来在网上找原因的时候,发现有网友反应脚本中如果应用declare也会出现类似情况, 即在sh中执行就报错“delcare: not found”,在bash中就可以畸形执行。