一个批量添加用户的shell/ target=_blank class=infotextkey>shell脚本,供大家学习参考。
复制代码 代码如下:
#!/bin/bash
#useradd andpassword
echo "please input username:"
read name
echo "please input number:"
read num
n=1
while [ $n -le $num ]
do
useradd $name$n
n=`expr $n + 1 `
done
#/etc/shasow info
echo "please input passwd"
read passwd
m=1
while [ $m -le $num ]
do
echo $passwd |passwd --stdin $name$m >/dev/null
m=`expr $m + 1 `
done