Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/5/84; site ellie.UUCP
Path: utzoo!watmath!sunybcs!ellie!colonel
From: colonel@ellie.UUCP (Col. G. L. Sicherman)
Newsgroups: net.sources
Subject: moving a .newsrc
Message-ID: <486@ellie.UUCP>
Date: Wed, 7-Aug-85 16:11:42 EDT
Article-I.D.: ellie.486
Posted: Wed Aug  7 16:11:42 1985
Date-Received: Thu, 8-Aug-85 00:05:42 EDT
Distribution: net
Organization: A-1 Mosquito Farms
Lines: 46

:	newnewsrc - make a new .newsrc conform to an old one.
:	Col. G. L. Sicherman.  7 Aug 1985.
:
:	Have you ever moved from one system to another and found that
:	you must customize a whole new .newsrc, because the old system
:	numbered its news articles differently?
:	This script imposes as much of an old .newsrc as possible on
:	a new .newsrc.  Specifically, it disables groups that were
:	disabled on the old system, and arranges groups into the old
:	order.
:
:	usage:	newnewsrc [-e] [-b] [-o] OLD NEW
:
:	-e	Enable disabled groups on NEW that were enabled on OLD.
:	-b	Place groups not found on OLD at beginning of NEW
:			rather than at end.
:	-o	Do not import "option" lines from OLD.
:
:	New file is written to standard output.
:
bflag='10000'
eflag='~'
oflag='=='
while (true) do
case $1 in
-b*)	bflag='70000'; shift;;
-e*)	eflag='!~'; shift;;
-o*)	oflag='!='; shift;;
*) break;
esac
done
if (test 2 != $#) then
echo 'usage: newnewsrc [-e] [-b] [-o] old new' >&2
exit 1
fi
awk '{print "O",NR+'$bflag',$0}' < $1 > /usr/tmp/$$
awk '{print "N",NR+40000,$0}' < $2 | sort +2 -3 +0 - /usr/tmp/$$ |\
awk '$3 !~ /[:!]$/ {if ($1'$oflag'"O") print; next}\
substr($3,0,length($3)-1)==substr(LSTNM,0,length(LSTNM)-1) \
{if ($3'$eflag'/!$/) LSTNM=$3; print $1, $2, LSTNM, LSTRG; F=0; next}\
0 < F {print LAST; F=0}\
{if ("O"==$1) LSTRG=""; else LSTRG=$4; LSTNM=$3; \
LAST=$1 " " $2 " " LSTNM " " LSTRG; F=1}\
END {if (0