From harvard!uucp Mon Nov 18 19:38:16 1985 Received: from harvard.HARVARD.EDU by seismo.CSS.GOV with SMTP; Mon, 18 Nov 85 19:12:32 EST Received: by harvard.HARVARD.EDU; Mon, 18 Nov 85 19:14:24 EST From: harvard!uucp (Black Hole) Return-Path: Received: by panda.LOCAL on Mon, 18 Nov 85 18:38:51 est Date: Mon, 18 Nov 85 18:38:51 est Message-Id: <8511182338.AA22137@panda.LOCAL> To: talcott!seismo!rick Subject: newsweed Status: R Date: Sun, 11 Nov 84 15:12:12 pst From: decvax!decwrl!turtlevax!ken (Ken Turkowski) Subject: Re: Table of contents for news Newsgroups: mod.sources Subject: Newsweed: a program to delete unwanted news articles # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # newsweed newsweed.1 echo x - newsweed cat > "newsweed" << '//E*O*F newsweed//' #! /bin/sh TEMP=/tmp/weed$$ : ${NEWSRC=$HOME/.newsrc} trap 'rm ${TEMP}?; exit' 0 2 echo Making list of article titles readnews -l $* | sort -o ${TEMP}a if test -s ${TEMP}a then cp ${TEMP}a ${TEMP}b echo Please remove article titles which you do not wish to read sleep 1 # Delete the next line if you don't have reset reset # So that vi's CRLF doesn't get trashed by another vi ${EDITOR-vi} ${TEMP}b if cmp -s ${TEMP}a ${TEMP}b then echo No articles deleted. else comm -23 ${TEMP}a ${TEMP}b | sed 's/ .*//' > ${TEMP}c echo Removing unwanted articles cp $NEWSRC $NEWSRC.old awk 'BEGIN { groupcount = 1 } /^options/ { options = $0 } /^[^/]*:/ { # .newsrc input -- subscribed group j = index($0, ":") group = substr($0, 1, j-1) i = groupindex[group] = groupcount++ newsgroup[i] = group grouptype[i] = ":" newsread[i] = substr($0, j+2) # list of articles read } /^[^/]*!/ { # .newsrc input -- unsubscribed group j = index($0, "!") group = substr($0, 1, j-1) i = groupindex[group] = groupcount++ newsgroup[i] = group grouptype[i] = "!" newsread[i] = substr($0, j+2) # list of articles read } /^[^ /]+\/[0-9]+/ { # readnews -l output j = index($0, "/") group = substr($0, 1, j-1) i = groupindex[group] if (!i) { # not previously encountered i = groupindex[group] = groupcount++ newsgroup[i] = group grouptype[i] = ":" } k = index($0, " ") if (k == 0) article = substr($0, j+1) else article = substr($0, j+1, k-j-1) if (newsread[i]) newsread[i] = newsread[i] "," article else newsread[i] = article } END { if (options != 0) print options for (i = 1; i < groupcount; i++) { n = split(newsread[i], artlist, ",") for (j = 1; j <= n; j++) { if (split(artlist[j], range, "-") == 1) { rangelist[j] = artlist[j] } else { artlist[j] = range[1] rangelist[j] = range[2] } } # sort articles sorted = 0 start = 1 while (sorted == 0) { sorted = 1 for (j = start; j < n; j++) { if (j == start && !artlist[start]) { start++ continue } if (artlist[j+1] < artlist[j]) { # swap temp = artlist[j+1] artlist[j+1] = artlist[j] artlist[j] = temp temp = rangelist[j+1] rangelist[j+1] = rangelist[j] rangelist[j] = temp sorted = 0 } if (artlist[j] && rangelist[j]+1 == artlist[j+1]) { # merge artlist[j+1] = artlist[j] artlist[j] = "" rangelist[j] = "" } } } printf "%s%s", newsgroup[i], grouptype[i] first = 1 for (j = start; j <= n; j++) { if (artlist[j]) { if (first == 0) printf "," else printf " " first = 0 if (artlist[j] != rangelist[j]) printf "%d-%d", artlist[j], rangelist[j] else printf "%d", artlist[j] } } printf "\n" } }' $NEWSRC.old ${TEMP}c > ${TEMP}d cp ${TEMP}d $NEWSRC fi else echo No news. fi //E*O*F newsweed// echo x - newsweed.1 sed 's/^x//' > "newsweed.1" << '//E*O*F newsweed.1//' x.TH NEWSWEED 1 local x.SH NAME xnewsweed x.SH SYNOPSIS x.B newsweed x[readnews options] x.br x.B readnews x.SH DESCRIPTION x.I Newsweed xis a program to help in managing the vast number of articles xin the network news. xIt is used to delete articles that are not interesting xbefore using x.IR readnews , x.IR vnews , xor x.I rn xto read them. x.PP xA while after invoking x.I newsweed, xthe user is presented with a list of titles of news articles xin his preferred editor, xas indicated by the environment variable EDITOR x(\fIvi\fR is the default). xThen the user deletes lines containing titles of undesired articles, xwrites the file, xand lets x.I newsweed xmodify the x.I .newsrc xfile so that the undesired articles will not be presented. xThe previous x.I .newsrc xis saved as x.I .newsrc.old. xIf a newsrc file other than $HOME/.newsrc is desired, xone may set the environment variable x.I NEWSRC xto an appropriate filename. x.PP xTypically, one ends up deleting 80% of new news, xand saving an immense amount of time. x.SH FILES x~/.newsrc x.SH SEE ALSO xreadnews(1), vnews(1), rn(1), checknews(1) x.SH AUTHOR xKen Turkowski (turtlevax!ken) x.SH BUGS xThe title file is presented in alphabetical order xand should remain in alphabetical order; xotherwise not all of the uninteresting articles will be deleted x(this could be fixed with yet one more sort, though). x.PP xIt may take a long time to generate the titles file if x.I newsweed xis used to catch up on a backlog of news, xas after returning from vacation; xthe csh ^Z stop signal is useful to put newsweed into the background xduring phases other than the EDIT phase. x.PP xThe options line must not be continued with tabs on subsequent lines. x.PP xSome machines may not like long command lines, xso the awk program may need to be put into a file. x.PP xSmall machines may bomb because of the large amount of memory xused when there are a lot of newsgroups. xI suspect that the awk script could be rewritten xto be more conservative of memory. //E*O*F newsweed.1// echo Possible errors detected by \'sum\' [hopefully none]: temp=/tmp/shar$$ trap "rm -f $temp; exit" 0 1 2 3 15 cat > $temp <<\!!! 30088 3 newsweed 51017 2 newsweed.1 !!! sum newsweed newsweed.1 | sed 's=[^ ]*/==' | diff -b $temp - exit 0