Shell script to list what's NOT in the history file

Geoff Kuenning geoff at desint.UUCP
Mon Nov 19 03:56:00 AEST 1984


The following script locates all files in the usenet spool directory that
are not listed in the history file.  Since "expire" runs off of the history
file, these are files that will never be removed from the spooling
directories.

Cut at the line below, and don't forget to also remove my signature at the
end!
------------------------CUT HERE-----------------------------
#!/bin/sh
#
#	%W%	%G% %U%
#
#	Compare the usenet history file with the actual contents of the
#	spool directories, and report any discrepancies.
#
#	Usage:
#
#		histmiss libdir spooldir [extra find options]
#
#	If no find options are given, all plain files in the spool directories
#	are reported, even if they do not have an all-numeric name.
#
#	Examples:
#
#	To remove anything that is not in the history file:
#
#		histmiss /usr/{lib,spool}/news | xargs rm -f
#
#	To remove anything that is both not in the history file, and is more
#	than two weeks old (this could be run on a daily basis as a backup
#	form of expire):
#
#		histmiss /usr/{lib,spool}/news -mtime +14 | xargs rm -f
#
LIBDIR=$1
SPOOLDIR=$2
shift; shift
TEMP=/tmp/hm$$
PATH=/bin:/usr/bin
export PATH

trap "rm -f $TEMP; exit 1" 1 2 15
cut '-d	' -f3- $LIBDIR/history | tr . / | tr -s ' ' \\012 | sort -u > $TEMP
cd $SPOOLDIR
find . -type f $* -print | sed 's/^\.\///' | sort -u | comm -23 - $TEMP
rm -f $TEMP
exit 0
------------------------CUT HERE-----------------------------
-- 

	Geoff Kuenning
	First Systems Corporation
	...!ihnp4!trwrb!desint!geoff



More information about the Comp.sources.unix mailing list