Thread View: news.software.readers
6 messages
6 total messages
Started by Seth J. Bradley
Mon, 19 Jul 1993 23:46
.newsrc Cleanup Program Sought
Author: Seth J. Bradley
Date: Mon, 19 Jul 1993 23:46
Date: Mon, 19 Jul 1993 23:46
12 lines
1397 bytes
1397 bytes
A while back, someone posted a .newsrc cleanup program - I believe it was a Perl script. It condensed the lines by taking the first and last number and replacing all the numbers in between with a "-". Does anyone have this lying around? Thanks in advance! -- Seth J. Bradley, Senior System Administrator, Intel SSD-CT Internet: sbradley@scic.intel.com UUCP: uunet!scic.intel.com!sbradley ---------------------------------------- "A system admin's life is a sorry one. The only advantage he has over Emergency Room doctors is that malpractice suits are rare. On the other hand, ER doctors never have to deal with patients installing new versions of their own innards!" -Michael O'Brien
Re: .newsrc Cleanup Program Sought
Author: Hans de Graaff
Date: Tue, 20 Jul 1993 06:15
Date: Tue, 20 Jul 1993 06:15
18 lines
1485 bytes
1485 bytes
In <1993Jul19.234609.2029@scic.intel.com> Seth J. Bradley <sbradley@scic.intel.com> wrote: >A while back, someone posted a .newsrc cleanup program - I believe it was >a Perl script. It condensed the lines by taking the first and last >number and replacing all the numbers in between with a "-". Does anyone >have this lying around? Thanks in advance! You might mean fixnewsrc, a perl-script which originally could be used to sort your .newsrc in a specific order. I hacked it up some to also delete numbered ranges from unsubscribed groups. You can get it at dutiws.twi.tudelft.nl:/pub/news Hans -- Hans de Graaff | I want someone to follow, J.J.deGraaff@IS.TWI.TUDelft.NL | who doesn't lead the way Department of Informatics | I want someone to listen, Delft University of Technology | who won't repeat what I say
Re: .newsrc Cleanup Program Sought
Author: Tim Pierce
Date: Tue, 20 Jul 1993 07:47
Date: Tue, 20 Jul 1993 07:47
29 lines
1530 bytes
1530 bytes
In article <1993Jul19.234609.2029@scic.intel.com>
sbradley@scic.intel.com (Seth J. Bradley) writes:
>A while back, someone posted a .newsrc cleanup program - I believe it was
>a Perl script.
This is the one I use. I think Peter da Silva contributed the regexp
magic. A clever sed hacker could probably use the contents of the
"while" loop to rewrite this in sed, too.
#!/usr/local/bin/perl
$HOME = $ENV{HOME};
$NEWSRC = "$HOME/.newsrc";
$TMP = "$HOME/.tmpnewsrc";
open (TMP, ">$TMP");
open (NEWSRC);
while (<NEWSRC>) {
s/[-,][-,0-9]*[-,]/-/ if /!/;
print TMP $_;
}
rename ($NEWSRC, "$HOME/.oldnewsrc");
rename ($TMP, $NEWSRC);
--
____ Tim Pierce / "Oh, it's a *Unix* system!"
\ / twpierce@unix.amherst.edu /
\/ (BITnet: TWPIERCE@AMHERST) / -- Lex, in JURASSIC PARK
Re: .newsrc Cleanup Program Sought
Author: Kartik Subbarao
Date: Thu, 22 Jul 1993 16:58
Date: Thu, 22 Jul 1993 16:58
22 lines
1601 bytes
1601 bytes
In article <22g7un$4f4@amhux3.amherst.edu> twpierce@unix.amherst.edu (Tim Pierce) writes: >In article <1993Jul19.234609.2029@scic.intel.com> >sbradley@scic.intel.com (Seth J. Bradley) writes: > >>A while back, someone posted a .newsrc cleanup program - I believe it was >>a Perl script. > >This is the one I use. I think Peter da Silva contributed the regexp >magic. A clever sed hacker could probably use the contents of the >"while" loop to rewrite this in sed, too. ``script''? Why bother with the -,0-9 business? This is what I do: % perl -i -pe 's/\!.*/\!/g' .newsrc (The \ before the ! is for my shell) Occassionaly, I'll also do: % (grep : ~/.newsrc; grep \! ~/.newsrc) > /tmp/new; mv /tmp/new ~/.newsrc Two lines. No muss, no fuss. -Kartik
Re: .newsrc Cleanup Program Sought
Author: Dana Carson
Date: Thu, 22 Jul 1993 22:00
Date: Thu, 22 Jul 1993 22:00
125 lines
4046 bytes
4046 bytes
In article <22g7un$4f4@amhux3.amherst.edu> twpierce@unix.amherst.edu (Tim Pierce) writes:
>In article <1993Jul19.234609.2029@scic.intel.com>
>sbradley@scic.intel.com (Seth J. Bradley) writes:
>
>>A while back, someone posted a .newsrc cleanup program - I believe it was
>>a Perl script.
>
>This is the one I use. I think Peter da Silva contributed the regexp
>magic. A clever sed hacker could probably use the contents of the
>"while" loop to rewrite this in sed, too.
>
>#!/usr/local/bin/perl
>$HOME = $ENV{HOME};
>$NEWSRC = "$HOME/.newsrc";
>$TMP = "$HOME/.tmpnewsrc";
>
>open (TMP, ">$TMP");
>open (NEWSRC);
>
>while (<NEWSRC>) {
> s/[-,][-,0-9]*[-,]/-/ if /!/;
> print TMP $_;
>}
>
>rename ($NEWSRC, "$HOME/.oldnewsrc");
>rename ($TMP, $NEWSRC);
That is short and fast but has the problem, at least in my mind that
it will compress out marked articles. I may read news differently from
many people but if I M an article I don't want the cleanup to mark ir as
read for me. This is my news cleaning perl script. It just deletes
totally the article string for unread groups since I'll need to do a
catchup if start reading them anyway.
I also was a little paranoid checking for errors, the question with
computers isn't should you be paranoid, but are you paranoid enough.
For this reason it writes the new .newsrc to stdout so you can save it
and do the rename yourself.
-------------------------------------------------------------------------------
#!/usr/local/bin/perl -w
$NEWSDIR = "/usr/spool/news/";
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
if ($group =~ /:/) {
( $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;
}
--
Dana Carson
Westinghouse Electronic Systems Group Mail Stop 1615
net: carson@tron.bwi.wec.com |
...!uunet!tron!carson | This message on recycled bits.
AT&T: (410) 765-3513 |
WIN: 285-3513 |
Re: .newsrc Cleanup Program Sought
Author: Tim Pierce
Date: Wed, 28 Jul 1993 06:03
Date: Wed, 28 Jul 1993 06:03
15 lines
1387 bytes
1387 bytes
In article <1993Jul22.220039.20824@tron.bwi.wec.com> carson@tron.bwi.wec.com (Dana Carson) writes: > That is short and fast but has the problem, at least in my mind that >it will compress out marked articles. I may read news differently from >many people but if I M an article I don't want the cleanup to mark ir as >read for me. Do you really care if you don't read the group in question? This script, after all, only affects unsubscribed newsgroups. -- ____ Tim Pierce / "Oh, it's a *Unix* system!" \ / twpierce@unix.amherst.edu / \/ (BITnet: TWPIERCE@AMHERST) / -- Lex, in JURASSIC PARK
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