[alt.sources] .newsrc file fixer

jeff@quark.WV.TEK.COM (Jeff Beadles) (10/01/89)

This is a little script that I tossed together to massage my .newsrc.  I tried
to edit it with 'vi' to move the order of some of the groups around, and clean
it up a bit.  Well, vi choked, as some of the lines were too long.
(>1024 characters)  Since I didn't feel line braving 'emacs', I decided to
write this script.  (No editor wars, please! :-)

This will take some of the fairly long lines from your .newsrc, and compress
them into something a little more reasonable.  (People really don't leave
marked messages in the middle of groups for a long time, right? :-)

Anyway, have at it.  If you like it, great.  If not, then I suggest unlink(2).

	-Jeff
-- 
Jeff Beadles		Utek Engineering, Tektronix Inc.
jeff@quark.WV.TEK.COM


#--------------------------------CUT HERE-------------------------------------
#! /bin/sh
#
# This is a shell archive.  Save this into a file, edit it
# and delete all lines above this comment.  Then give this
# file to sh by executing the command "sh file".  The files
# will be extracted into the current directory owned by
# you with default permissions.
#
# The files contained herein are:
#
# -rwxr-xr-x  1 jeff         1296 Oct  1 09:30 fixnewsrc
#
echo 'x - fixnewsrc'
if test -f fixnewsrc; then echo 'shar: not overwriting fixnewsrc'; else
sed 's/^X//' << '________This_Is_The_END________' > fixnewsrc
X#!/bin/sh
X## Copyright 1989, Jeff Beadles.  Permission is granted to freely distribute.
X## Submittor:	Jeff Beadles   jeff@quark.WV.TEK.COM
X## Name:	fixnewsrc
X## Date:	Sun Oct  1 09:25:33 PDT 1989
X## Machine:	BSD Unix
X## OS:		unix
X## Version:	1.0
X## Synopsis:	Fix long lines in .newsrc
X##
X## Description:
X##
X##	This program will take the long lines created by rn in a .newsrc
X##	file, and shorten with them.  (mark all articles as read)
X##	It takes lines that look like this:
X##
X##  talk.politics.misc! 1-1234,1235-19210,19212,19245-20322
X##
X##	and changes it to:
X##
X##  talk.politics.misc! 1-20322
X##
X##	This helps, as if you try to use 'vi', it chokes on lines longer
X##	than 1024 characters or so.  Also, it probably speeds up the
X##	start-up time of rn.
X##
X##	When done, a backup copy of .newsrc is saved in .newsrc.old
X##
X
X## Change directory to the user's home directory
Xcd
X
X## Check for a .newsrc file.
Xif [ ! -f .newsrc ] ; then
X	echo "$0: .newsrc not found."
X	exit 1
Xfi
X
X## Check for a .newsrc.old file, and remove if needed.
Xif [ -f .newsrc.old ] ; then
X	rm -f .newsrc.old
Xfi
X
X## Make that backup first...
Xcp .newsrc .newsrc.old
X
X## There is a space and a tab in the first two []'s below.
Xsed '/!/s/^\([^ 	][^ 	]*\).*[,-][,-]*\([0-9][0-9]*\)$/\1 1-\2/' \
X	< .newsrc.old > .newsrc
Xexit 0
________This_Is_The_END________
if test `wc -c < fixnewsrc` -ne 1296; then
	echo 'shar: fixnewsrc was damaged during transit (should have been 1296 bytes)'
fi
fi		; : end of overwriting check
exit 0