Chinaunix首页 | 论坛 | 博客
  • 博客访问: 245675
  • 博文数量: 68
  • 博客积分: 2802
  • 博客等级: 少校
  • 技术积分: 614
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-11 15:38
文章存档

2013年(3)

2012年(15)

2011年(21)

2010年(29)

我的朋友

分类: LINUX

2010-03-18 23:05:47

#! /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) |
0

上一篇:awk应用小结

下一篇:20100318-1

给主人留下些什么吧!~~