#!/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"