rdm@cfcl.UUCP (Rich Morin) (04/10/88)
: : unread - get multi-column counts of unread news groups : # Uses UNIX tools instead of rn -c; runs faster, doesn't blow up... # # Written by Rich Morin, CFCL, April, 1988. # Borrows from work by Jeff Forys and Don Gworek. if [ ! -f $HOME/.newsrc ]; then echo "unread: no .newsrc file, fergeddit..." exit 1 fi t=/tmp/unread_$$ trap "rm -f $t; exit 0" 0 2 15 sort /usr/lib/news/active > $t sed -n ' s@: .*[-,]@: @ s@: @ @p ' $HOME/.newsrc | sort | join - $t | # foo.bar <lastread> <lastactive> <firstactive> <modflag> # $1 $2 $3 $4 $5 awk ' BEGIN { COLS = 3 WIDTH = 26 LIMIT = WIDTH - 7 # foo.bar.baz (123) BLANX = " " } { i = $4-1 if ($2 > i) i = $2 unread = $3-i if (unread < 1) # boring, ignore it... next group = $1 len = length(group) if (len > LIMIT) # too long, truncate beginning... group = "?" substr(group,1+len-LIMIT) string = group " (" unread ")" BLANX printf("%s", substr(string,1,WIDTH)) if (++cols == COLS) { # start new line print "" cols = 0 } } END { if (cols > 0) print "" } ' -- _ o _ |_ _ _ _ _ o _ Canta Forda Computer Laboratory | | | | | | | | | | | | | | UNIX software consulting and training | | |_ | | | | | |_| | | | | {hoptoad,ptsfa}!cfcl!rdm +1 415 994 6860