30 lines
439 B
Bash
Executable File
30 lines
439 B
Bash
Executable File
#!/bin/bash
|
|
|
|
|
|
usage() {
|
|
echo "usage : $0 <users.txt>"
|
|
exit 1
|
|
}
|
|
|
|
if [[ $# != 1 ]] ; then
|
|
usage
|
|
fi
|
|
|
|
fich=$1
|
|
if [[ ! -r $fich ]] ; then
|
|
echo "i$0: erreur ouverture fichier $fich"
|
|
exit 2
|
|
fi
|
|
while read ligne
|
|
do
|
|
login=$(echo "${ligne}"|cut -f1 -d:)
|
|
#echo $login
|
|
nom=$(echo "${ligne}"|cut -f2 -d:)
|
|
#echo $nom
|
|
if getent passwd "${login}" > /dev/null 2 >&1
|
|
then
|
|
sudo userdel -r -f "${login}"
|
|
fi
|
|
#echo $ligne
|
|
done < $fich
|