shell批量删除用户

@努力的小王  March 29, 2018
#!/usr/bin/env bash
while read line
do
       user=`echo $line |awk -F":" '{print $1}'`
       shell=`echo $line |awk -F":" '{print $NF}'`
       if [ "$shell" = "/bin/bash" -a "$user" != "root" ];then

               userdel -r $user
               if [ $? -eq 0 ];then
               echo "$user is deleted success"
               let i++
               fi
        fi
done  < /etc/passwd

echo "total: $i"

添加新评论