kose5@kose5-Aspire-4552:~$ for((i=0;i<=5;i++));do
> echo $i;
> done
0
1
2
3
4
5
kose5@kose5-Aspire-4552:~$ cat rand.sh
#!/bin/bash
for((i=0;i<=5;i++));do
echo $i;
done
kose5@kose5-Aspire-4552:~$ sh rand.sh
rand.sh: 2: Syntax error: Bad for loop variable
超简单脚本,无法运行?
-
- 帖子: 919
- 注册时间: 2009-07-01 22:04
超简单脚本,无法运行?
bash不如perl精妙,学不到lisp的皮毛,远不够c++强悍,不过可以用。
- ebok
- 帖子: 852
- 注册时间: 2008-02-15 0:09
Re: 超简单脚本,无法运行?
既然是#!/bin/bash
为何要用sh去执行脚本,用sh执行脚本会导致很多bash的新特性无法使用.
为何要用sh去执行脚本,用sh执行脚本会导致很多bash的新特性无法使用.
Somebody think they are full of niubility, so they play a zhuangbility, but only reflect their shability.
-
- 帖子: 919
- 注册时间: 2009-07-01 22:04
- ebok
- 帖子: 852
- 注册时间: 2008-02-15 0:09
Re: 超简单脚本,无法运行?
用#!/bin/sh与 sh scriptname 一样
要想用 ./scriptname 请先加x 权限
想学shell请看ABS ==> <<advanced bash shell scripting>>
要想用 ./scriptname 请先加x 权限
想学shell请看ABS ==> <<advanced bash shell scripting>>
Somebody think they are full of niubility, so they play a zhuangbility, but only reflect their shability.
-
- 帖子: 919
- 注册时间: 2009-07-01 22:04
-
- 帖子: 919
- 注册时间: 2009-07-01 22:04
Re: 超简单脚本,无法运行?
活见鬼了,昨天x加来加去都不行,今天可以了,可能是昨天rp不好, 无语。
还是要谢谢ebox。
还是要谢谢ebox。
bash不如perl精妙,学不到lisp的皮毛,远不够c++强悍,不过可以用。