29 lines
427 B
Bash
Executable File
29 lines
427 B
Bash
Executable File
#!/bin/bash
|
|
#set -o errexit
|
|
set -o nounset
|
|
if [ $# != 1 ]
|
|
then
|
|
echo "usage : $0 <fichier>"
|
|
exit 1
|
|
fi
|
|
fich="$1"
|
|
if ! [[ -r "${fich}" ]]; then
|
|
echo "$0 : erreur ouverture fichier ${fich}"
|
|
exit 2
|
|
fi
|
|
while read -r ligne
|
|
do
|
|
login=$(echo "${ligne}" |cut -f1 -d':')
|
|
|
|
echo "${login}"
|
|
getent passwd "${login}" >> /dev/null
|
|
if [[ $? = 0 ]]
|
|
then
|
|
userdel -r "${login}"
|
|
fi
|
|
done < "${fich}"
|
|
|
|
exit 0
|
|
|
|
|