adduser.txt 

adduser.sh 从adduser.txt读取数据然后批量添加用户
#!/bin/bash
#add many user by shell
while read LINES
do
username=`echo $LINES | cut -d ' ' -f1` # cut命令
password=`echo $LINES | cut -d ' ' -f2`
#echo "username is $username"
#echo "psw is $password"
useradd $username
# echo "the res code is $?"
if [[ $? -ne 0 ]]; then # $?
echo "user added "
else
echo $password | passwd --stdin $username
fi

done < adduser.txt
userdel.sh 从adduser.txt读取数据然后批量删除用户
#!/bin/bash
while read line
do
username=`echo $line | cut -d ' ' -f1`
userdel -r $username # delete the user home dir too
if [[ $? -eq 0 ]]; then
echo "delete $username yes"
else
echo "something wrong"
fi
done < adduser.txt



adduser.sh 从adduser.txt读取数据然后批量添加用户
#!/bin/bash
#add many user by shell
while read LINES
do
username=`echo $LINES | cut -d ' ' -f1` # cut命令
password=`echo $LINES | cut -d ' ' -f2`
#echo "username is $username"
#echo "psw is $password"
useradd $username
# echo "the res code is $?"
if [[ $? -ne 0 ]]; then # $?
echo "user added "
else
echo $password | passwd --stdin $username
fi

done < adduser.txt
userdel.sh 从adduser.txt读取数据然后批量删除用户
#!/bin/bash
while read line
do
username=`echo $line | cut -d ' ' -f1`
userdel -r $username # delete the user home dir too
if [[ $? -eq 0 ]]; then
echo "delete $username yes"
else
echo "something wrong"
fi
done < adduser.txt

