home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / question / 9622 < prev    next >
Encoding:
Text File  |  1992-07-30  |  1.6 KB  |  52 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!usc!cs.utexas.edu!asuvax!ennews!enuxhb.eas.asu.edu!sridhar
  3. From: sridhar@enuxhb.eas.asu.edu (Sridhar Venkataraman)
  4. Subject: Re: How to find out what groups I belong to
  5. Message-ID: <1992Jul31.033324.29336@ennews.eas.asu.edu>
  6. Sender: news@ennews.eas.asu.edu (USENET News System)
  7. Organization: Arizona State University, Tempe AZ
  8. References: <ratner.712534982@ficus.cs.ucla.edu> <1992Jul31.003031.14370@convex.com> <SHUBU.92Jul30205847@oporto.cs.utexas.edu>
  9. Date: Fri, 31 Jul 1992 03:33:24 GMT
  10. Lines: 40
  11.  
  12. shubu@cs.utexas.edu (Shubhendu Sekhar Mukherjee) writes :
  13. )>>>>> Tom Christiansen <tchrist@convex.COM> writes:
  14. )TC> From the keyboard of ratner@ficus.cs.ucla.edu (David Ratner):
  15. )TC> :
  16. )TC> :
  17. )TC> :/usr/ucb/groups [login-name]
  18. )TC> :
  19. )TC> :Just typing "groups" with no arguments lists the groups you are in.
  20. )TC> :Specifying a login-name lists the groups that person is in.
  21. )
  22. )TC> Yes, but we still haven't told him how to list out all the 
  23. )TC> members in a given group.
  24. )
  25. )/usr/bin/ypcat group | grep <groupname>
  26.  
  27. Atleast on our system (4.3 BSD Tahoe) we don't have YP.
  28. /usr/bin/ypcat: Command not found.
  29.  
  30. I lack the expertise in awk/perl/sed but the following should give the
  31. results...
  32.  
  33. ----script1-----
  34. #!/bin/sh
  35. name=$1
  36. awk -F: "/^$name/ { print \$3  ; exit } " /etc/group
  37.  
  38. ----script2-----
  39. #!/bin/sh
  40. id=$1
  41. awk -F: "\$4 == $id {print \$1}" /etc/passwd
  42.  
  43. script1 <groupname> should print the group id.
  44. script2 <groupid> should fetch the members of the group.
  45.  
  46. Yes, I know there are 2 invocations of awk and /bin/sh.. (to guard
  47. against wizard flames :-)
  48.  
  49. )-Shubu
  50.  
  51. Sridhar.
  52.