#!/bin/sh
# @(#) $Header: topgroups,v 1.3 98/01/04 20:05:38 leres Exp $ (LBL)
#
# topgroups - list the top N groups that have been read recently
#
# Run this after rotating the syslog's each day
#

##  =()<. @<_PATH_SHELLVARS>@>()=
. /usr/news/etc/innshellvars

n=250
if [ $# -ge 1 ] ; then
    n=$1
fi

cat $MOST_LOGS/syslog.0 | \
  awk '$5 ~ /^nnrpd/ {if ($7 == "group") {print $8}}' | \
  sort | \
  uniq -c | \
  sort -rn | \
  head -$n
