[comp.unix.wizards] YP answer

limes@ouroborous.Eng.Sun.COM (MIDI Apprentice) (09/19/89)

In article <2130@munnari.oz.au> ok@cs.mu.oz.au (Richard O'Keefe) writes:
>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.
>Again, watch out for Yellow Pages; if you're using that you have to do
>	ypcat passwd | grep "^${LOGNAME}" | what-ever-you-want-here

Assuming that a YP lookup operation is more efficient then doing a YP
database dump and groveling through it with grep, the following will
probably be somewhat faster (my passwd map is around 2500 entries):

	ypmatch $LOGNAME passwd | cut -f5 -d:

Add error checking [and salt] to taste.
-- Greg Limes	limes@sun.com	...!sun!limes	73327,2473	[choose one]

ok@cs.mu.oz.au (Richard O'Keefe) (09/19/89)

In article <124894@sun.Eng.Sun.COM>, limes@ouroborous.Eng.Sun.COM (MIDI Apprentice) writes:
: In article <2130@munnari.oz.au> ok@cs.mu.oz.au (Richard O'Keefe) writes:
: >Again, watch out for Yellow Pages; if you're using that you have to do
: >	ypcat passwd | grep "^${LOGNAME}" | what-ever-you-want-here

: Assuming that a YP lookup operation is more efficient then doing a YP
: database dump and grovelling through it with grep, the following will
: probably be somewhat faster (my passwd map is around 2500 entries):
: 	ypmatch $LOGNAME passwd | cut -f5 -d:

My point was to _beware_ of Yellow Pages.
The manual page says of ypmatch that "No pattern matching is available".
If you're looking for an exact match, ypmatch is fine.  For anything else,
ypcat | grep is the way to go.