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