On Dec 14 19:00:53, Leonardo Rodrigues wrote:
> Ok! Here goes my contribution to this thread!
> 
> # $1=group
> # $2=user
> 
> cd /etc
> cat ./group \
>         | sed '/'$1'/ s/'$2'//' \

Hm, that's a nice one too: for every line in /etc/group that contains '$1',
remove the first occurence of '$2'. Go on :-)


>         | sed '/'$1'/ s/,,/,/' \
>         | sed '/'$1'/ s/,$//' \
>         | sed '/'$1'/ s/:,/:/' > group.new
> 
> mv /etc/group.new /etc/group
> chown root.wheel /etc/group
> chmod 644 /etc/group
> exit 0
> 
> 
> On Tue, Dec 14, 2010 at 10:31 AM, Jan Stary <h...@stare.cz> wrote:
> > On Dec 14 15:31:40, OpenBSD Geek wrote:
> >> Hi,
> >>
> >> After posted many requests on how to remove user from a group, i choosed
> >> to build my own script.
> >> And it works very fine.
> >>
> >> if [ $1 ] & [ $2 ]; then
> >> cp /etc/group /tmp
> >> cat /tmp/group | grep ^$2 > /tmp/onlygroup
> >> cat /tmp/group | grep -v ^$2 > /tmp/nogroup
> >> cat /tmp/onlygroup | sed "s/$1//g" | \
> >>         sed "s/ /,/g" | sed "s/,,/,/g" | sed "s/,$//g" > /tmp/newgroup
> >> cat /tmp/newgroup >> /tmp/nogroup
> >> cat /dev/null > /tmp/group
> >> cat /tmp/nogroup >> /tmp/group
> >> cp /tmp/group /etc
> >> chmod 644 /etc/group
> >> chown root /etc/group
> >> chgrp wheel /etc/group
> >
> > Among other hilariously horrible things,
> > this bit just made my day:
> >
> >> rm -f /tmp/*
> >> echo "Success."
> >
> > You just nuked everybody's tempfiles.
> > That's quite a success I guess.
> >
> >
> >> else
> >> echo "Remove user from a group"
> >> echo "Use : sh duig user group"
> >> fi
> >>
> >> Cheers,
> >>
> >> Wesley MOUEDINE ASSABY
> >> www.mouedine.net

Reply via email to