shell 脚本.sh: 2: Syntax error: Bad for loop variable

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
AlwaysOnline
帖子: 15
注册时间: 2009-05-23 18:38

shell 脚本.sh: 2: Syntax error: Bad for loop variable

#1

帖子 AlwaysOnline » 2009-06-07 14:45

shell 脚本>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/sh
for((i=0;i<20;i=$i+1))
do
echo $i
if [$i=lt 10];then
echo''
continue
fi
echo'THIS IS A TWO DIGITAL NUMERIC'
done

提示错误:
iang-laptop:~/sellforlder$chmod +x countinue.sh
iang-laptop:~/shellfolder$ ./continue.sh

./continue.sh: 2: Syntax error: Bad for loop variable

请教高手.初来乍到...................
U初出茅庐`挑战困难`屹立不倒`坚持不懈[*][*][*]AlwaysOline[/b]
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

Re: shell 脚本.sh: 2: Syntax error: Bad for loop variable

#2

帖子 bones7456 » 2009-06-07 21:52

for i in `seq 20`
好了
关注我的blog: ε==3
头像
543082593
帖子: 234
注册时间: 2008-11-07 8:41

Re: shell 脚本.sh: 2: Syntax error: Bad for loop variable

#3

帖子 543082593 » 2009-06-07 23:34

代码: 全选

if [$i=lt 10];then
是你发帖的时候 打错的 还是 你写脚本的时候没注意 很明显 应该是

代码: 全选

if [ $i -lt 10 ] ; then
fall again
smooth criminal
they don't care about us
billie jean
beat it
dangerous
the lost children
childhood
ben
i will be there
speechless
she is out of my life
rock with you
...
LOVE U FOREVER
回复