After correction, i'm agree it is a bit long, but it works.
Thank you very much for your posts!

if [ $1 ] & [ $2 ]; then

tempfile=`mktemp /tmp/tempfile.XXXX`
cp /etc/group $tempfile

onlygroup=`mktemp /tmp/tempfile.XXXX`
cat $tempfile | grep ^$2 > $onlygroup

nogroup=`mktemp /tmp/tempfile.XXXX`
cat $tempfile | grep -v ^$2 > $nogroup

cat $onlygroup | sed "s/$1//g" | \
        sed "s/ /,/g" | sed "s/,,/,/g" | sed "s/,$//g" >> $nogroup

mv /etc/group /etc/group.old
cp $nogroup /etc/group

chmod 644 /etc/group
chown root /etc/group
chgrp wheel /etc/group

rm -f /tmp/tempfile.????

else
echo "Remove user from a group"
echo "Use : sh duig user group"
fi

Reply via email to