home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!usc!cs.utexas.edu!asuvax!ennews!enuxhb.eas.asu.edu!sridhar
- From: sridhar@enuxhb.eas.asu.edu (Sridhar Venkataraman)
- Subject: Re: How to find out what groups I belong to
- Message-ID: <1992Jul31.033324.29336@ennews.eas.asu.edu>
- Sender: news@ennews.eas.asu.edu (USENET News System)
- Organization: Arizona State University, Tempe AZ
- References: <ratner.712534982@ficus.cs.ucla.edu> <1992Jul31.003031.14370@convex.com> <SHUBU.92Jul30205847@oporto.cs.utexas.edu>
- Date: Fri, 31 Jul 1992 03:33:24 GMT
- Lines: 40
-
- shubu@cs.utexas.edu (Shubhendu Sekhar Mukherjee) writes :
- )>>>>> Tom Christiansen <tchrist@convex.COM> writes:
- )TC> From the keyboard of ratner@ficus.cs.ucla.edu (David Ratner):
- )TC> :
- )TC> :
- )TC> :/usr/ucb/groups [login-name]
- )TC> :
- )TC> :Just typing "groups" with no arguments lists the groups you are in.
- )TC> :Specifying a login-name lists the groups that person is in.
- )
- )TC> Yes, but we still haven't told him how to list out all the
- )TC> members in a given group.
- )
- )/usr/bin/ypcat group | grep <groupname>
-
- Atleast on our system (4.3 BSD Tahoe) we don't have YP.
- /usr/bin/ypcat: Command not found.
-
- I lack the expertise in awk/perl/sed but the following should give the
- results...
-
- ----script1-----
- #!/bin/sh
- name=$1
- awk -F: "/^$name/ { print \$3 ; exit } " /etc/group
-
- ----script2-----
- #!/bin/sh
- id=$1
- awk -F: "\$4 == $id {print \$1}" /etc/passwd
-
- script1 <groupname> should print the group id.
- script2 <groupid> should fetch the members of the group.
-
- Yes, I know there are 2 invocations of awk and /bin/sh.. (to guard
- against wizard flames :-)
-
- )-Shubu
-
- Sridhar.
-