A single datapoint for "head" hecklers:
[554] mxc@suse61: time ypcat hosts | wc -l
18259
real 0m11.435s
user 0m0.340s
sys 0m0.050s
[555] mxc@suse61: time ypcat hosts | head -1 | wc -l
1
real 0m0.176s
user 0m0.050s
sys 0m0.010s
[556] mxc@suse61: ypwhich
yphost
[557] mxc@suse61: ping -c 4 yphost
PING yphost (153.32.2.254): 56 data bytes
64 bytes from 153.32.2.254: icmp_seq=0 ttl=254 time=1.332 ms
64 bytes from 153.32.2.254: icmp_seq=1 ttl=254 time=1.473 ms
64 bytes from 153.32.2.254: icmp_seq=2 ttl=254 time=1.487 ms
64 bytes from 153.32.2.254: icmp_seq=3 ttl=254 time=2.837 ms
--- yphost ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 1.332/1.782/2.837 ms
Seems worthwhile give the "wc -l" approach; I'd probably try
if ypwhich -m $map 2>&1 >/dev/null; then
myself, but I don't know enough to be confident that there aren't lots of
empty maps being served in the world. I also don't know whether the exit
status of 'ypwhich' can be trusted across likely implementations/versions.
So, keeping with the check-ypcat-stdout approach:
if ypcat $map 2>/dev/null | read dummy; then
I'm a little more confident that that will work in likely Bourne shell
variants.
--
Mark Carmichael