宝慕林2162443
2015-07-26 18:11
#!/bin/bsah
#批量添加指定数量的用户
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=1;i<$num;i=i+1 ))
do
/usr/sbin/useradd $name$i &>/dev/null
echo $pass | /usr/bin/passwd --stdin $name$i &>/dev/null
done
fi
fi
我照着视频写的,为什么我的创建不了用户啊?
y需要变量需要有初始值
y=0
shell编程之条件判断与流程控制
35507 学习 · 139 问题
相似问题