6 echo "Syntax: ./remove-user.sh <username>"
10 COUNT
=`grep -E -c "^$1:" $ETC/passwd`
11 if [ "$COUNT" -ne "1" ]; then
12 echo "fatal: user '$1' doesn't appear to exist (or exists multiple times, or contains regexpy characters)."
15 GROUPS
=`sed -rn '/[,:]'$1'(,|$)/ s/:.*$// p' $ETC/group`
16 if [ "$GROUPS" ]; then
17 echo "User '$1' is still part of these groups:" $GROUPS
18 echo "fatal: this simplistic script cannot remove users from groups."
21 sed -i "/^$1:/ d" $ETC/passwd
23 echo "User (+SSH key) removed."