home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10437 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  1.7 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!sdd.hp.com!hpscdc!hplextra!hpcc05!hpyhde4!hpycla!hpergfg2!hprdash!hprpcd!tmilner
  2. From: tmilner@hprpcd.rose.hp.com (Tom Milner)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: I want a program that prints out base gid's of any user
  5. Message-ID: <15360003@hprpcd.rose.hp.com>
  6. Date: 26 Aug 92 20:12:40 GMT
  7. References: <BtIqyp.F5A@news.cso.uiuc.edu>
  8. Organization: Performance Technology Center, Roseville
  9. Lines: 31
  10.  
  11. In comp.unix.questions, bzg52408@uxa.cso.uiuc.edu (Benjamin Z. Goldsteen) writes:
  12.  
  13.  
  14. |       I have been trying to write a program that prints out the
  15. |    base gid of a user (given on the command line).  I have tried
  16. |    using awk and perl, but I can not get anything decent.
  17. |    Can show me how to do this.  One thing I have tried
  18. |    [ gid username ]
  19. |    #! /usr/bin/awk -f
  20. |    BEGIN { FS=":"; FILENAME="/etc/passwd" }
  21. |    ARGV[1] == $1 {print $4}
  22. |
  23. |    I am not sure if 1 if right for ARGV, but whatever...anyway, it 
  24. |    won't read from /etc/passwd - it only reads from stdin.  I can;t
  25. |    make it do otherwise.
  26. |
  27. |    I don't really understand perl...
  28. |
  29. |    Thanks
  30.  
  31. Try the "id" command ... as in 
  32. id | sed "s/.*(\(.*\))/\1/"
  33.                                   _____________________________________
  34.                                  /_______________  ___________________/
  35.                                                 / /
  36.                                                / /
  37.                                               / / Tom Milner (Tn: 785-5637)
  38.                                              / /  HP Performance Tech Center
  39.                                             / /   tom@hpptc16.rose.hp.com
  40.                                            /_/    __________________________
  41.                     
  42.