[net.sources] cleaning news archive files

z@rocksvax.UUCP (Jim Ziobro) (09/07/84)

	For those who keep archives of stuff from net.sources using an
Alan Watt lbgm (little bird gave me) style archive then you might
want a convenient way to delete the junk that may get saved there.

	I have written some small scripts which make that job easier.
When you come across junk simply pipe the offending article into
zap.so and it creates a script which will remove the article from
your lbgm archive.  After your finished reading news just invoke tozap
which was created by zap.so.

	I have include Alan Watt's original article.  As always please
keep me informed of enhancements or bugs.


File: lbgmX
----------
: lbgmX - X file with a message-id of $1 from a lbgm archive
: "HISTORY"
: " 06-Sep-84  z at XEROX Henrietta "
:	" Created by Jim Ziobro "
:

lbgmdir=/usr/lbgm
: lbgmdir is archive location
cd $lbgmdir

: get filename from Message-Id
filenam=`awk  'BEGIN { filid = "" ; FS = ":" }\
\
	{\
	if ( filid == "" ) filid = $1 ;\
	if ( $0 ~ /^[	 ]*$/ ) filid = "" ;
	# line following blank has filename
	}\
\
\
/^	[Mm][eE][sS][sS][aA][gG][eE]-[Ii][Dd]:/	{\
	if ( $2 == "'"$1"'" )\
	print filid ;\
	}\
	' < save.log `

: "$filenam is filename to be purged from lbgm archive"
: X the files
X *save.log
sed -e /$filenam"/,/^	$/d" < \#save.log > save.log
X $filenam
----------
File: zap.so
----------
: Extract a Message-Id from a news file and prepend an lbgmX
: used to help keep lbgm archives clean
: called from readnews with "s | zap.so"
: outputs a file $HOME/tozap
: archive can then be cleaned by invoking tozap
: "HISTORY"
: " 06-Sep-84  z at XEROX Henrietta "
:	" Created by Jim Ziobro "
:

: extract Message-Id
awk  'BEGIN { mid = "" ; FS = ":" }\
\
/^[Mm][eE][sS][sS][aA][gG][eE]-[Ii][Dd]/	{\
	if ( mid == "" ) mid = $2 ;\
	printf("lbgmX \"%s\"\n", mid) ;\
	}\
	'\
	>> $HOME/tozap 

chmod +x $HOME/tozap
----------
File: X
----------
for i do mv $i \#$i; done
----------

	The original article:
----------
From rocheste!seismo!harpo!decvax!ittvax!swatt Fri Apr  8 17:01:12 1983
Subject: savesource script
Newsgroups: net.sources


I don't have space to save all news forever, but I decided some time
ago that net.sources was worth keeping around, hence "savesource".
Usage is from you news "sys" file:

	SOURCES:net.sources:B:/usr/lib/news/savesource [ srcdir ]

where <srcdir> is where you want the stuff to go.  In there will
appear the file "save.log", which contains the news header of
every news article saved, and files of the form:

	${month}_${day}.${unique}

(as in "Apr_8.4552"), each file containing an article.  The log
file will point to the saved article.  There is a lockout against
concurrent runnings of savesource.

You have to periodically go in by hand and delete obvious junk
(discussions and requests for stuff), and also to weed out which
version you want to keep if something is posted several times.
I have everything posted on net.sources since August 15th of last
year.

	- Alan S. Watt
	{decvax,duke,purdue,lbl-csam}!ittvax!swatt

sed 's/^X//' >savesource <<!EOF
X#! /bin/sh
X: '/*********************************************************************
X	savesource
X		Save sources sent over net.sources.
X		Called as a news forwarding program from inews
X
X	Alan S. Watt
X   
X	Sccsid="@(#)savesource	1.1 8/15/82 (ITT)"
X
X	usage:
X		savesource [ savedir ]
X
X	arguments:
X		savedir		Directory area to save sources (default
X				is /usr/lbgm).
X   
X	history:
X		08/15/82	original version
X   *********************************************************************/'
X
X: 'Public source directory (Little Bird Gave Me)'
Xsourcedir=${1-"/usr/lbgm"}
X
X: 'format of date command: "Sun Aug 15 15:56:06 EDT 1982"'
Xset `date`
Xmon=$2
Xday=$3
Xuniq=$$
Xtmp=svsrc.$$.tmp
Xlogfile=save.log
X
X: 'Lock the save source file and dump standard input there'
Xcd $sourcedir
X>$tmp
Xwhile savefile="${mon}_${day}.$uniq"
Xdo
X	if ln $tmp $savefile 2>&-
X	then
X		break
X	fi
X	uniq=`expr $uniq + 1`
Xdone
Xcat >${savefile}
Xrm -f $tmp
X
X: 'Dump the news header in a log file (up to a blank line)'
Xheader="$savefile:
X`sed -n '1,/^$/s/^/	/p' ${savefile}`"
Xecho "${header}" >>$logfile
!EOF

-- 
//Z\\
James M. Ziobro
Ziobro.Henr@Xerox.ARPA
{rochester,amd,sunybcs,allegra}!rocksvax!z