[root@nginx scripts]# cat useradd.sh
#!/bin/sh
#editor tangbo
#QQ 79313760
################start#########################
USERS_INFO=/root/addusers.txt
USERADD=/usr/sbin/useradd
PASSWD=/usr/bin/passwd
CUT=/bin/cut
while read LINES
do
USERNAME=`echo $LINES | $CUT -f1 -d ' '`
PASSWORD=`echo $LINES | $CUT -f2 -d ' '`
$USERADD $USERNAME
if [ $? -eq 0 ]
then
echo "$USERNAME exists,skip set password"
else
echo $PASSWORD | $PASSWD --stdin $USERNAME > /dev/null 2>&1
fi
done < $USERS_INFO
###########################end######################################
[root@nginx ~]# cat addusers.txt
bebepay201501 password201501
bebepay201502 password201502
bebepay201503 password201503
bebepay201504 password201504
bebepay201505 password201505
bebepay201506 password201506
bebepay201507 password201507
bebepay201508 password201508
bebepay201509 password201509
bebepay201510 password201510
bebepay201511 password201511
[root@nginx ~]#
转载于:https://blog.51cto.com/cqtangbo/1754566