当前位置: 技术问答>linux和unix
大家有时间帮我看一下为什么这个简单的脚本老出现错误
来源: 互联网 发布时间:2017-02-25
本文导语: #!/bin/sh #a shell to add 100 nweusers num=1 n=20 while[ $n -ge $num ] do useradd 'newuser'$num echo 1234 | passwd --stdin 'newuser'$num "$num"":ok,the $num newusers is 'newuser'$num" num=`expr $num + 1` done 运行时...
#!/bin/sh
#a shell to add 100 nweusers
num=1
n=20
while[ $n -ge $num ]
do
useradd 'newuser'$num
echo 1234 | passwd --stdin 'newuser'$num
"$num"":ok,the $num newusers is 'newuser'$num"
num=`expr $num + 1`
done
运行时老出现这垃圾错误,我要疯了
sh-3.2# sh useradd
useradd: line 5: while[20 -ge 1]: command not found
useradd: line 6: syntax error near unexpected token `do'
useradd: line 6: `do'
我就费解了,我第五行怎么改都是这个错误
#a shell to add 100 nweusers
num=1
n=20
while[ $n -ge $num ]
do
useradd 'newuser'$num
echo 1234 | passwd --stdin 'newuser'$num
"$num"":ok,the $num newusers is 'newuser'$num"
num=`expr $num + 1`
done
运行时老出现这垃圾错误,我要疯了
sh-3.2# sh useradd
useradd: line 5: while[20 -ge 1]: command not found
useradd: line 6: syntax error near unexpected token `do'
useradd: line 6: `do'
我就费解了,我第五行怎么改都是这个错误
|
while 后面与[之间,要有空格
while [ $n -ge $num ]
do
while [ $n -ge $num ]
do