28 lines
401 B
Bash
Executable File
28 lines
401 B
Bash
Executable File
#!/bin/bash
|
|
|
|
#set -e
|
|
set -u
|
|
|
|
if [[ $# -ne 1 ]] ; then
|
|
echo "usage : $0 <fichier>"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -r "$1" ]] ; then
|
|
echo "$0 : erreur ouverture ${fich}"
|
|
exit 2
|
|
fi
|
|
|
|
fich=$1
|
|
|
|
while read -r ligne
|
|
do
|
|
login=$(echo "${ligne}"|cut -d: -f1)
|
|
getent passwd "${login}" > /dev/null
|
|
if [[ $? -eq 0 ]] ; then
|
|
sudo userdel --remove "${login}"
|
|
echo "Utilisateur ${login} supprime"
|
|
fi
|
|
|
|
done < "${fich}"
|