Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!aplcen!uakari.primate.wisc.edu!ames!uhccux!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.unix.wizards Subject: Re: awk and shell question Keywords: awk sh Message-ID: <2130@munnari.oz.au> Date: 18 Sep 89 13:02:59 GMT References: <1163@ispi.UUCP> <2412@netcom.UUCP> Sender: news@cs.mu.oz.au Lines: 17 In article <2412@netcom.UUCP>, hinton@netcom.UUCP (Greg Hinton) writes: : In article <1163@ispi.UUCP> jbayer@ispi.UUCP (Jonathan Bayer) writes: : >I have to get the user id, and then get the user description from /etc/passwd. : How about this: : grep \^`who am i | cut -d' ' -f1`\: /etc/passwd | cut -d: -f5 Watch out for BSD-derived systems, where the first "word" from the "who am i" command has the form "machine!user", e.g. munmurra!ok. You want the bit after the !. A much simpler method is to use a shell variable. Check "environ" in the manual, and you'll find that you have LOGNAME # System V or USER # BSD or both. Just do grep "^${LOGNAME}:" /etc/passwd | what-ever-you-want-here Again, watch out for Yellow Pages; if you're using that you have to do ypcat passwd | grep "^${LOGNAME}" | what-ever-you-want-here