#! /bin/sh
#
# |-----------------------------------------------------------|
# | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc.      |
# | All Rights Reserved                                       |
# |-----------------------------------------------------------|
# |          Restricted Rights Legend                         |
# | Use, duplication, or disclosure by the Government is      |
# | subject to restrictions as set forth in                   |
# | subparagraph (c)(1)(ii) of the Rights in Technical        |
# | Data and Computer Software Clause of DFARS 252.227-7013.  |
# |         MIPS Computer Systems, Inc.                       |
# |         950 DeGuigne Avenue                               |
# |         Sunnyvale, California 94088-3650, USA             |
# |-----------------------------------------------------------|
#
# $Header: rmjunk,v 1.6.2.1 92/06/24 13:47:48 marker Exp $
#	remove files of dubious worth
#	Removes all files that match the patterns listed in the filelist file
#	starting at <starting-directory> (default /)
#	that are more than <days> old (default 4).

#!	chmod +x ${file}

if [ $# -lt 1 ]
then
	echo >&2 "Usage:  $0 filelist [ starting-directory ] [ days ]"
	exit 1
fi

#	generate list of -name arguments for find
if [ ! -r $1 ]
then
	echo >&2 "$0:  cannot read file '$1'"
	exit 1
fi
names=`sed -n '	/^#/d
		s/[ 	]\{1,\}#.*//
		/^[ 	]*$/d
	 '"	/./ s/.*/-o -name '&'/p
	 "  $1  |
	sed '1s/-o //'`
if [ -z "${names}" ]
then
	echo >&2 "$0:  no file names!"
	exit 1
fi

eval find ${2:-/} -type f -atime +${3:-4} '\(' ${names} '\)' \
	-print -exec rm {} '\;'
