#!/bin/bash
cat user.txt | while read line
do
user=$(echo $line | cut -d ' ' -f1)
passwd=$(echo $line | cut -d ' ' -f2)
useradd -r -m -s /bin/bash $user >/dev/null
if [ $? -eq 0 ];
then
echo $user":"$passwd | chpasswd
echo "$user create success!"
else
echo "$user exists,skip set passwd"
fi
done
user.txt内容格式:
aaa 123
bbb 123