Newsgroup peruser (shell script)
Oscar M. Nierstrasz
oscar at utcsrgv.UUCP
Thu Apr 12 07:50:32 AEST 1984
Here is a (Bourne) shell script for perusing newsgroups
that you don't normally read. It compiles a list of
subject headings for all unread articles starting from
the last one you read. With the -a flag, all articles
are listed (done automatically if last-read article
has expired). Arguments are newsgroups (eg: `ns net.sources').
The output could conceivably be edited into shell script
that selects the articles you're interested in ...
Enjoy!
------------------------- cut here ----------------------
#! /bin/sh
# ns [-a] newsgroups ...
# List subject headings of articles in listed newsgroups
# starting at last-read article in .newsrc.
# With the -a flag all articles are listed.
# Author : Oscar Nierstrasz @ utcsrgv!oscar
case $# in
0 ) echo 'Usage: ns [-a] <news group> ...' 1>&2
exit ;;
esac
nrc=$HOME/.newsrc
if test ! -r $nrc
then
echo "ns : Can't find $nrc" 1>&2
exit
fi
n=/usr/spool/news
s='/^Subject:/ { print FILENAME ": " $0 ; exit }'
case $1 in
-a ) all=y
shift ;;
* ) all=n ;;
esac
for i
do
d=`echo $i | sed "s/\./\//g"`
if test ! -d $n/$d
then
echo "$i : no such newsgroup" 1>&2
else
cd $n/$d
echo
echo "--- $i : $n/$d ----"
echo
case $all in
y ) f=all ;;
n ) f=`sed -n "/^$i:/s/.*-//p" $nrc`
case $f in
"" ) f=all ;;
* ) if test ! -r $f
then
f=all
fi ;;
esac ;;
esac
case $f in
all ) for j in *
do
awk "$s" $j
done ;;
* ) while test -r $f
do
awk "$s" $f
f=`expr $f + 1`
done ;;
esac
fi
done
More information about the Comp.sources.unix
mailing list