#! /usr/bin/sh
#删除添加的用户,每次只有删一个用户
time=$(date)
username=`echo -n $(awk -F ":" '{ print $1 }' /etc/passwd)`
#uid=$(id $1|awk -F "[ (=]" '{print $2}')
if [ -z "$1" ]
then
echo
echo "arg error!please into username you want to delete!\n"
echo "USERLIST is '$username'!\nPlease input username!\n"
exit 0
fi
id $1 2>/root/tmp18.txt
string=$(cat /root/tmp18.txt)
if [ -z "$string" ]
then
echo "warning:Are you sure to delete user '$1'[y/n]?\n"
read answer
if [ "$answer" = "y" ]
then
userdel $1
echo "delete user '$1'!message saved in /root/message.txt\n"
echo "$time have deleted user '$1'! ">>/root/message.txt
else
echo "$time have not deleted user '$1'! ">>/root/message.txt
fi
else
echo $string;echo
echo "Wrong username!!!\nUSERLIST is '$username'!\nPlease input username! \n"
echo "$time have not deleted user '$1'! ">>/root/message.txt
fi
exit 0
阅读(508) | 评论(0) | 转发(0) |