Catching up on News (toolsmith's solution)

Dermot G. Harriss dgharriss at watmath.waterloo.edu
Wed Sep 13 05:32:32 AEST 1989


In article <16340 at watdragon.waterloo.edu> cgwong at watdragon.waterloo.edu (Clint Wong) writes:
>> >Is there a quick way in rn to mark all unread articles as being read?
>> 
>This is not quite what I was looking for.  I want to catch-up on ALL of
>my currently subscribed newsgroups all at once.  This is useful when trying
>to move your .newsrc to another machine and all the article numbers are
>different or when you come back from a long vacation and there are a zillion
>Unread articles in a hundred groups.

In rn?  As a guess, no.  "c" when the current group is $ at the newsgroup
selection level doesn't have the intuitive effect of catching up all
groups.  You'd have to write a macro or something.  Steve? ;-)

But you can achieve the same effect by munging your .newsrc to set the 
last read article numbers to the server's last received article numbers 
as recorder in the news active file.  Here's an awk (actually new awk)
tool I just whipped up to do this:

BEGIN {
	FS = "[ \t]+"
}
{
	entry = $1
	group = substr (entry, 1, length (entry)-1)
	while (getline < "active" > 0) {
		if ($1 == group) {
			printf ("%s 1-%d\n", entry, $2)
			break
		}
	}
	close "active"
}

1. put the above script in the directory where your .newsrc is
   (let's call it "doit").
2. use getactive(8) to get your server's active file: type
	getactive active
   in the same directory where .newsrc and doit are.
3. save your old .newsrc:
	mv .newsrc .newsrc~
3. type the following:
	nawk -f doit < .newsrc~ > .newsrc
   This will take a while if your .newsrc contains many groups or your
   machine is slow (or both).  You can "tail -f .newsrc" if you like to
   see how (or if) things are progressing.

The above script is very inefficient.  The active file (which is huge)
is opened and read for every line of your .newsrc file.  If your .newsrc
file happened to be alphabetically sorted by group name, then you could
eliminate the `close "active"' line, making it considerably faster.
It's a 3 minute hack - I don't claim it's beautiful or robust or anything.

UW.UNIX STEVE HAYMAN MEMORIAL AWK HACKERS CHALLANGE!!!

	make it faster!  make it beautiful!
	hint: check out awk arrays...

enjoy.
							-- Dermot


P.S.
As for moving your .newsrc to a machine served by a different news server,
see fix_newsrc(8).




More information about the Comp.unix mailing list