I had 3 responses, so I include them all:Quote:>>I would like to be able to specify a netgroup and get a list of all the
>>machines in that netgroup - has anybody done this already ?
Well, you could obviously write a quick perl script to do this, but in the
rare instances I want to do this I just use the NIS netgroup.byhost map and
ypcat -k netgroup.byhost | egrep '[ ,]comp[, ]|,comp$'
to get a list of the hosts in the "comp" netgroup. A quick pipe into cut(1)
will pretty up the output for you if you'd prefer it that way.
ypcat -k netgroup.byhost | egrep '[ ,]comp[, ]|,comp$' | cut -d. -f1
Obviously this could be translated into a shellscript or shell alias.
Please note, this can miss some special cases, like only one host in the
netgroup, but you can easily extend the regex to cover it.
Here's a sed command I conned a friend into creating.
It does not recurse the tree, however.
ypmatch netgroup_name netgroup | sed -e "s:(\([^,][^,]*\),[^(][^(]*:\1 :g"
If you can use C code instead, try
File: /pub/netgroup.tar.z (gzip'ed)
It can print netgroups and do various set operations on them.
Thanks to all, for what I want the top is the most useful (though how would I extend the egrep to cover just one name in the group?