Linux下批量刪除某個前綴的用戶

Linux下批量刪除某個前綴的用戶。。。
#!/bin/bash
read -p "Please Input username prefix is:" prefix
 if [ -z $prefix ]
then
 echo "Error: NO username prefix"
exit 1
 fi
del=$(grep "$prefix" /etc/passwd | cut -d: -fL | grep -v root)
 if [ -z "$del"]
then
echo "No username prefix is $prefix"
else
 tar zcf /root/userinfo.tar.gz -C /etc passwd shadow group gshadow &>/dev/null 做好備份
for deluser in $del
do
userdel -r $del &>/dev/null
echo user $US is delete Successfull
done
fi
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章