#! /usr/bin/sh
#删除以std开头的10个固定名称用户
time=$(date)
username=`echo -n $(awk -F ":" '{ print $1 }' /etc/passwd)`
for n in 01 02 03 04 05 06 07 08 09 10
do
echo "warning:Are you sure to delete user 'std$n'[y/n]?\n"
read answer
if [ "$answer" = "y" ]
then
userdel std$n 2>/root/tmp.txt
string=$(cat /root/tmp.txt)
if [ -z "$string" ]
then
echo "delete user 'std$n'!message saved in /root/message.txt\n"
echo "$time have deleted user 'std$n'! ">>/root/message.txt
else
echo $string;echo
echo "$time have not deleted user 'std$n'! ">>/root/message.txt
echo "Please make sure that user is in USERLIST=='$username'\n"
fi
else
echo "$time have not deleted user 'std$n'! ">>/root/message.txt
echo "Please make sure that user is in USERLIST=='$username'\n"
fi
done
阅读(551) | 评论(0) | 转发(0) |