home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10422 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.3 KB  |  40 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!mcsun!Germany.EU.net!murignis!ap542!D012S436!frank
  3. From: frank@D012S436.sniap.mchp.sni.de ()
  4. Subject: Re: I want a program that prints out base gid's of any user
  5. Message-ID: <1992Aug27.094930.11516@sniap.mchp.sni.de>
  6. Sender: news@sniap.mchp.sni.de (News Admin)
  7. Organization: Siemens-Nixdorf AG
  8. References: <BtIqyp.F5A@news.cso.uiuc.edu>
  9. Date: Thu, 27 Aug 92 09:49:30 GMT
  10. Lines: 28
  11.  
  12. bzg52408@uxa.cso.uiuc.edu (Benjamin Z. Goldsteen) writes:
  13. :    I have been trying to write a program that prints out the
  14. : base gid of a user (given on the command line).  I have tried
  15. : using awk and perl, but I can not get anything decent.
  16. : Can show me how to do this.  One thing I have tried
  17. : [ gid username ]
  18. :  #!/usr/bin/awk -f
  19. : BEGIN { FS=":"; FILENAME="/etc/passwd" }
  20. : ARGV[1] == $1 {print $4}
  21. : I am not sure if 1 if right for ARGV, but whatever...anyway, it 
  22. : won't read from /etc/passwd - it only reads from stdin.  I can;t
  23. : make it do otherwise.
  24.  
  25. How about:
  26.  
  27. #!/bin/sh
  28. USER=$1
  29. </etc/passwd awk '
  30.  BEGIN { FS=":" }
  31.  "'$USER'" == $1 {print $4}
  32. '
  33. --
  34. Frank O'Dwyer                           Disclaimer: 
  35. Siemens-Nixdorf AG                             I will deny everything
  36. Tel.  : +49 (89) 636-40639                      Fax.  : +49 (89) 636-45860
  37. e-mail: Frank.ODwyer@sniap.mchp.sni.de
  38.