๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
8 messages
8 total messages Started by Tom Betz Thu, 13 Jun 1996 00:00
shell script to clean up .newsrc files?
#22779
Author: Tom Betz
Date: Thu, 13 Jun 1996 00:00
24 lines
1244 bytes
A long time ago, in a Usenet far away, somebody wrote and posted
a shell script that went through .newsrc files and cleaned them up,
taking out all the commas and making every Newsgroup look like:

comp.os.xenu: 1-982763

or:

comp.os.ms-dos! 1-645763

I used it once, and it worked great, but I have lost it over
the years.  Will someone who still has it please email it to me, 
or post it here, or both?

Thanks.

-- 
-- Tom Betz ---------- <http://www.pobox.com/tbetz> -------- (914) 375-1510 --
 tbetz@pobox.com  | We have tried ignorance for a very long | tbetz@panix.com
------------------+ time, and it's time we tried education. +-----------------
---------- I mock up my reactive mind seven times before breakfast. ----------

Re: shell script to clean up .newsrc files?
#22813
Author: Jan B. Schipmolder
Date: Fri, 14 Jun 1996 00:00
19 lines
1085 bytes
In article <4ppmh7$rr1@panix3.panix.com>, tbetz@panix.com (Tom Betz) wrote:

] A long time ago, in a Usenet far away, somebody wrote and posted
] a shell script that went through .newsrc files and cleaned them up

Check out /usr/local/nuglops/bin/groupsort

Here is the relevant blurb extracted from /usr/local/nuglops/list:

groupsort     zconcept
          much-praised utility for sorting newsgroups
          Usage: groupsort <newsgroups>

-- 
Jan B. Schipmolder
schip@netcom.com

shell script to clean up .newsrc files?
#22834
Author: Orjan Johansen
Date: Fri, 14 Jun 1996 00:00
19 lines
1085 bytes
In article <4ppmh7$rr1@panix3.panix.com>, Tom Betz <tbetz@panix.com> wrote:
>A long time ago, in a Usenet far away, somebody wrote and posted
>a shell script that went through .newsrc files and cleaned them up,
>taking out all the commas and making every Newsgroup look like:
>
>comp.os.xenu: 1-982763

What about:

#!/bin/sh
cd
mv .newsrc .newsrc~
sed -e 's/\([:!] [0-9]*\).*[,-]/\1-/' <.newsrc~ >.newsrc

Greetings,
๏ฟฝrjan.

Re: shell script to clean up .newsrc files?
#22891
Author: Jan B. Schipmolder
Date: Sat, 15 Jun 1996 00:00
24 lines
1185 bytes
In article <4pqoua$3j7@due.unit.no>, oerjan@lie.matstat.unit.no (Orjan
Johansen) wrote:

] In article <4ppmh7$rr1@panix3.panix.com>, Tom Betz <tbetz@panix.com> wrote:

] >A long time ago, in a Usenet far away, somebody wrote and posted
] >a shell script that went through .newsrc files and cleaned them up,

] What about:
] 
] #!/bin/sh
] cd
] mv .newsrc .newsrc~
] sed -e 's/\([:!] [0-9]*\).*[,-]/\1-/' <.newsrc~ >.newsrc

That worked for me in csh if I replaced ! by \!.
I guess in sh you don't need to do that.

-- 
Jan B. Schipmolder
schip@netcom.com

Re: shell script to clean up .newsrc files?
#22894
Author: Kim DeVaughn
Date: Sat, 15 Jun 1996 00:00
85 lines
3381 bytes
In article <4ppmh7$rr1@panix3.panix.com>, Tom Betz <tbetz@panix.com> wrote:
|
| A long time ago, in a Usenet far away, somebody wrote and posted
| a shell script that went through .newsrc files and cleaned them up,
| taking out all the commas and making every Newsgroup look like:
| 
| comp.os.xenu: 1-982763
| 
| or:
| 
| comp.os.ms-dos! 1-645763
| 
| I used it once, and it worked great, but I have lost it over
| the years.  Will someone who still has it please email it to me, 
| or post it here, or both?

Attached is what I use (with perl).  As written, it leaves the subscribed
groups [:] alone, and only cleans up the unsubscribed [!] ones.  If you
*really* want to (in effect) catchup the subscribed ones, as you imply
above, you'll need to modify it slightly.  You may also want to blow off
your .rnsoft and .rnlast (if using trn), or other "pointer files" if using
some other reader that creates such things.

I invoke the script using these csh aliases:

alias	trnclean "rm -f ~/.rnlast ~/.rnsoft"
alias	nupd	 "clean.newsrc;trnclean"


Thanks to Tom Christiansen for the original script ...!

[cc: emailed]

/kim


vvvvv snip vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

# From: Tom Christiansen <tchrist@mox.perl.com>
# Newsgroups: news.software.readers
# Subject: Re: trn:  clean up .newsrc file?
# Date: 21 Apr 1995 22:51:11 GMT
# Message-ID: <3n9csv$3g5@csnews.cs.colorado.edu>
# Organization: Perl Consulting and Training
#
#
# In article <arnsteinD6G5y0.F9M@netcom.com>,
#            David Arnstein <arnstein@netcom.com> wrote:
#
# > I use trn 3.4.1.  Trn's powerful cross-referencing features cause my
# > .newsrc file to fill up with long lists of article numbers, mainly in
# > groups that I am not subscribed to.  As a result, my .newsrc file is
# > over 750 Kbytes long!
# >
# > Most of the article numbers have long since been expired on my news
# > server, anyway.
# >
# > Is there a trn command that will get rid of article numbers that have
# > expired?  Any similar "clean up" features?
#
# I believe you'll find that this does what you want:
#
#       perl -i.old -pe 's/!.*\D(\d+)$/! 1-$1/' ~/.newsrc
#
# Poor csh users will probably have fun with the exclamation marks:
#
#       perl -i.old -pe 's/\!.*\D(\d+)$/\! 1-$1/' ~/.newsrc
#
# which works even in noncsh.
#
# If you have perl5, you can simplify your pattern to:
#
#       perl5 -i.old -pe 's/!.*?(\d+)$/! 1-$1/' ~/.newsrc
#
# But it's not strictly necessary.  (well, maybe for those "Newsgroup!1-100"
# cases without whitespace.)
#
# --tom

perl -i.old -pe 's/\!.*\D(\d+)$/\! 1-$1/' ~/.newsrc

^^^^^ snip ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Re: shell script to clean up .newsrc files?
#22909
Author: Larry W. Virden
Date: Sat, 15 Jun 1996 00:00
102 lines
3098 bytes

I have one script, BUT, it does not work as well as it should.  I can
share the one that has been hacked on, if some of you hard cores out 
there can help hack on it to make it better...


: # use perl
        eval 'exec perl -w -S $0 "$@"'
                if $runnning_under_some_shell;

#Author:carson@tron.bwi.wec.com (Dana Carson)
#Date: Wed, 16 Nov 1994 23:44:27 GMT
#Modified by: Larry W. Virden, to apply algorithm to all newsgroups
#Date: Mon, 21 Nov 1994

$NEWSDIR = "/usr/spool/news/";
if (!open(CURDIR,$NEWSDIR) ) {
	$NEWSDIR = "/var/spool/news/";
} else {
	closedir(CURDIR);
}

if ($ARGV[0] ) {
	open(RCFILE,$ARGV[0]) || die "Can't open $ARGV[0]";
} 
else {
	open(RCFILE,".newsrc") || die "Can't open .newsrc";
}
while (<RCFILE>) {
	($group, $seen) = split;
	print $group, " ";
	# if we read this group we need to trim expired gaps
	# if not an empty list will work
		( $GROUPDIR = $group ) =~ s;\.;/;g ;
		$GROUPDIR =~ s;[:!];/;g ;
		if (!opendir(CURDIR, $NEWSDIR . $GROUPDIR)) {
			print " \n";
			next;
		}
		@filenames = readdir(CURDIR);
		closedir(CURDIR);

		#find the ones that are numeric and therefore probably articles
		@articles = ();
		for (@filenames) {
			if(/^\d+$/) {
				push(@articles,$_);
			}
		}
		@articles = sort bynumber @articles;

		# if there are no articles go on to next group
		if (!defined($articles[0])) {
			print $seen,"\n";
			next;
		}
		$curlow = $articles[0];

		#break up the seen list
	 	@seen = split(/,/,$seen);
		while (@seen) {
			#find any gaps where the articles have expired
			#close up the gaps
			if ($seen[0] =~ /-/) {
	 			($clow,$chigh) = split(/-/,$seen[0]);
				last if $clow > $curlow;
				if ($chigh < $curlow) {
					shift(@seen);
					next;
				}
				else {
					$curlow = $chigh;
					shift(@seen);
					last;
				}
			}
			else {
				last if $seen[0] > $curlow;
				shift(@seen);
			}
		}
		@nlist = "1-".$curlow;
		@nlist = (@nlist,@seen);

		print join(",",@nlist);

		#write out the updated seen list
	print "\n";
}

sub bynumber {
	$a <=> $b;
}

-- 
:s Larry W. Virden                 INET: lvirden@cas.org
:s <URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
:s Unless explicitly stated to the contrary, nothing in this posting should
:s be construed as representing my employer's opinions.

Re: shell script to clean up .newsrc files?
#23021
Author: Alan Coopersmith
Date: Mon, 17 Jun 1996 00:00
20 lines
1370 bytes
schip@netcom.com (Jan B. Schipmolder) writes in news.software.readers:
|In article <4ppmh7$rr1@panix3.panix.com>, tbetz@panix.com (Tom Betz) wrote:
|
|] A long time ago, in a Usenet far away, somebody wrote and posted
|] a shell script that went through .newsrc files and cleaned them up
|
|Check out /usr/local/nuglops/bin/groupsort

/usr/local/nuglops is a netcom-specific directory (it stands for
something like Netcom User Group Local <?> Software), so how can
someone on panix.com check it out?

-- 
________________________________________________________________________
Alan Coopersmith                        alanc@godzilla.EECS.Berkeley.EDU
University of California, Berkeley           or: alanc@CSUA.Berkeley.EDU       


Re: shell script to clean up .newsrc files?
#23128
Author: Jan B. Schipmolder
Date: Wed, 19 Jun 1996 00:00
27 lines
1444 bytes
In article <4q4628$5au@agate.berkeley.edu>, 
alanc@godzilla.eecs.berkeley.edu (Alan Coopersmith) wrote:

] schip@netcom.com (Jan B. Schipmolder) writes in news.software.readers:

] |In article <4ppmh7$rr1@panix3.panix.com>, tbetz@panix.com (Tom Betz) wrote:

] |] A long time ago, in a Usenet far away, somebody wrote and posted
] |] a shell script that went through .newsrc files and cleaned them up

] |Check out /usr/local/nuglops/bin/groupsort

] /usr/local/nuglops is a netcom-specific directory

(Bangs head) You're right. I was sleeping. I'm so used to read that
question on netcom.* groups.

Somebody posted a /bin/sed solution though, a few days ago.

I mailed you the groupsort script. Hope you can make it work. Jan.

-- 
Jan B. Schipmolder
schip@netcom.com

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads