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