Shell script to list what's NOT in the history file
Frederick M. Avolio
avolio at grendel.UUCP
Sat Nov 24 00:11:08 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.
A good script and useful, too! I modified it to run on non-USG systems
(without cut and xarg).
Cut at the line below, and don'forget to remove my signature at the end.
------------------------CUT HERE-----------------------------
#!/bin/sh
#
# Version for 4.2BSD
#
# %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:
#
# rm -f `histmiss /usr/{lib,spool}/news`
#
# 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):
#
# rm -f `histmiss /usr/{lib,spool}/news -mtime +14`
#
LIBDIR=$1
SPOOLDIR=$2
shift; shift
TEMP=/tmp/hm$$
PATH=/bin:/usr/bin
export PATH
trap "rm -f $TEMP; exit 1" 1 2 15
awk -F\t '{ print $3 }' $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-----------------------------
--
Fred Avolio, DEC -- U{LTR,N}IX Support
301/731-4100 x4227
UUCP: {seismo,decvax}!grendel!avolio
ARPA: grendel!avolio at seismo.ARPA
More information about the Comp.sources.unix
mailing list