View Single Post
Old 15th December 2010
wesley wesley is offline
Real Name: Wesley
Shell Scout
 
Join Date: Aug 2009
Location: Reunion Island
Posts: 92
Default

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

Code:
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

install -o root -g wheel -m 644 $nogroup /etc/group

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

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

Last edited by wesley; 15th December 2010 at 04:14 PM. Reason: [code] shorter
Reply With Quote