请问这里有错吗? 为什么输入几个人用户,只能建一个。
#!/bin/bash
#批量添加指定数量的用户
read -p "please input user name: " -t 30 name
read -p "please input the number of users: " -t 30 num
read -p "please input the password of users: " -t 30 pass
if [ ! -z "$name" -a ! -z "$num" -a ! -z "$pass" ]
then
y=$(echo $num | sed 's/[ 0-9 ]//g')
if [ -z "$y" ]
then
for (( i=i;i<=$num;i=i+1 ))
do
/usr/sbin/useradd $name$! &>/dev/null
echo $pass | /usr/bin/passwd --stdin $name$i &>/dev/null
done
fi
fi