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

2013年(3)

2012年(15)

2011年(21)

2010年(29)

我的朋友

分类:

2010-03-19 11:06:39

#! /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
阅读(518) | 评论(0) | 转发(0) |
0

上一篇:20100318

下一篇:linux打包压缩命令

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