Ok, I made  little modification because if you were looking for a group id,
say 10, and a person's group id was 100 it would include them (I just added
the -w option after the first grep).  Now, how can I make it so it doesn't
include a user who's userid is the same as the groupid I am looking for ?

Here is the code I have now:

#!/bin/sh
TMP=`mktemp /tmp/group.XXXXXX`
grep -w `grep "^${1}:" /etc/group | cut -d: -f3` /etc/passwd | cut -d: -f1
> $TMP
grep "^${1}:" /etc/group | cut -d: -f4 | sed 's/,/\
/g' >> $TMP
cat $TMP | uniq
rm -f $TMP

-Bill
----- Original Message -----
From: "Gordon Messmer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 14, 2000 2:29 PM
Subject: Re: Group Email


> Charles Galpin wrote:
> > #!/bin/sh
> > #
> > # get's group members
> > # usage: getMembers group_name  > /etc/mail/group.lst
> > #
> > grep `grep $1 /etc/group | cut -d: -f3` /etc/passwd | cut -d: -f1
> >
> > create this script, and stick a call to it for each group list you want
to
> > maintain in a cron job, (or a little wrapper script in say
> > /etc/cron.daily), and you have a self maintaining group mail list. Add
> > salt as needed.
>
> Not bad, but not robust either.  It breaks easily.  How about the
> following:
>
>
> #!/bin/sh
> TMP=`mktemp /tmp/group.XXXXXX`
> grep `grep "^${1}:" /etc/group | cut -d: -f3` /etc/passwd | cut -d: -f1
> > $TMP
> grep "^${1}:" /etc/group | cut -d: -f4 | sed 's/,/\
> /g' >> $TMP
> cat $TMP | uniq
> rm -f $TMP
>
> This way, you also get those users who's default group isn't the one you
> requested, but are a member of all the same.
>
> > p.s. look bash boys - no perl! (and typed with one hand - restless baby
> > in other) <grin>
>
>
> Ooohh, it's sorely tempting  :)
>
>
> MSG
>
>
> --
> To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
> as the Subject.
>


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to