From bdb@becker.GTS.ORG Mon Jul 13 00:00:12 1992
From: bdb@becker.GTS.ORG (Bruce Becker)
Newsgroups: news.admin,news.newusers.questions
Subject: Re: Need .newsrc cleanup tool
Date: 12 Jul 92 17:18:34 GMT
Reply-To: news@becker.gts.org
Followup-To: news.newusers.questions
Organization: G. T. S., Toronto, Ontario

In article <1992Jul6.015835.1304@uvm.edu> wollman@sadye (Garrett Wollman) writes:
|In article <JIK.92Jul5202134@pit-manager.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes:
|>You can reduce the size of your .newsrc even more by eliminating *all*
|>numbers on newsgroups to which you do not subscribe:
|
|If your newsreader is smart about detecting new newsgroups, you can
|reduce the size of your .newsrc even more by eliminating *all*
|newsgroups to which you do not subscribe:
|
|  fgrep -v \! .newsrc >.newsrc.new
|
|(Modern versions of [rt]?rn, when used in conjunction with recent
|values of C news, are capable of determining the date of creation for
|a particular newsgroup, and determining its `newness' that way, rather
|than the old ``if it's not listed in .newsrc then it must be new''
|mechanism.)
|
|Of course, this has the disadvantage that you can't just search
|through your .newsrc looking for newsgroups like you can the active
|file, which can be a pain if you use NNTP and can't log in to your
|news server.  ([rt]rn come with a program called `getactive' which
|will retrieve a copy for you.)


	The following script will consolidate only
	unsubscribed .newsrc entries (but could easily
	be adapted for other needs):


cd $HOME
if [ \! -s .newsrc ]; then exit 1; fi
awk '
/.+!.*,/ {
	n = split($2, nn, ",")
	if (n == 1) print $1 " " $2
	else {
		s1 = nn[1]
		i = index(s1, "-")
		if (i > 0) s1 = substr(s1, 1, i-1)
		sn = nn[n]
		i = index(sn, "-")
		if (i > 0) sn = substr(sn, i+1)
		print $1 " " s1 "-" sn
	}
	next
}
{	print; next	}' .newsrc >.newnewsrc
if [ $? = 0 ]; then
	mv .newsrc .oldnewsrc
	mv .newnewsrc .newsrc
fi

-- 
  ,u,	 Bruce Becker			Toronto, Ontario
a /i/	 Internet: bdb@becker.gts.org	Uucp: ...!web!becker!bdb
 `\o\-e	 \*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/*\*/
 _< /_	 "Awaken the Geek Within" - Anthony Robot

