Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site umcp-cs.UUCP Path: utzoo!linus!philabs!seismo!rlgvax!cvl!umcp-cs!fred From: fred@umcp-cs.UUCP Newsgroups: net.sources Subject: shell script to find how many subscribe to each newsgroup Message-ID: <2940@umcp-cs.UUCP> Date: Mon, 3-Oct-83 19:54:44 EDT Article-I.D.: umcp-cs.2940 Posted: Mon Oct 3 19:54:44 1983 Date-Received: Wed, 5-Oct-83 09:09:40 EDT Distribution: net Organization: Univ. of Maryland, Computer Science Dept. Lines: 84 ##### The rest of this news item is a shell script. Execute ##### ##### it to extract the new shell script and its documentation. ##### : Run this shell script with "sh" not "csh" PATH=:/bin:/usr/bin:/usr/ucb export PATH all=FALSE if [ $1x = -ax ]; then all=TRUE fi /bin/echo 'Extracting subscribers' sed 's/^X//' <<'//go.sysin dd *' >subscribers #! /bin/sh # # @(#)subscribers.sh (University of Maryland) Fred Blonder 19-Aug-1983 # # Find out how many people subscribe to each newsgroup sub_tmp=/tmp/#s.$$ trap "rm -f $sub_tmp" 0 1 2 15 for dir in `awk -F: '{ print $6 }' /etc/passwd | sort -u` do # locate all login directories if # if .newsrc exists [ -r $dir/.newsrc ] then # find all newsgroups subscribed to, append to $sub_tmp awk -F: '/^net\..*: [0-9].*$/ { print $1 }' \ $dir/.newsrc >> $sub_tmp fi done # Count all ocurrences of all newsgroups. # Print result sorted by decreasing number of subscribers. awk '{ x[$1] = x[$1] + 1 } \ END { for (i in x) print i " " x[i] }' $sub_tmp | sort +1 -rn //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 555 subscribers /bin/echo -n ' '; /bin/ls -ld subscribers fi /bin/echo 'Extracting subscribers.6l' sed 's/^X//' <<'//go.sysin dd *' >subscribers.6l X.TH SUBSCRIBERS 6L "3-Oct-83 (U of Maryland)" X.SH NAME subscribers \- list how many people subscribe to each newsgroup X.SH SYNOPSIS X.I subscribers X.SH DESCRIPTION X.I Subscribers is a short shell script which looks into the password file, and everyone's $HOME/.newsrc file, to find out how many people subscribe to each newsgroup. The resulting list is written to the standard output as a series of lines of the form: X.sp X.ti +10 newsgroupname number-of-subscribers X.sp sorted by decreasing number of subscribers. X.SH AUTHOR Fred Blonder X.SH FILES X.in +15 X.ti -15 X/etc/passwd \- to find all login directories. X.br X.ti -15 $HOME/.newsrc \- (for each entry in /etc/passwd) to find each individual user's subscription list X.in -15 X.SH "SEE ALSO" readnews(1), news(5) X.SH DIAGNOSTICS None. X.SH BUGS Doesn't take into account multiple accounts using the same login directory, or people who change their $HOME directory. //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 444 subscribers.6l /bin/echo -n ' '; /bin/ls -ld subscribers.6l fi