#!/usr/bin/perl -w
#
#NAME
#  rmnew - remove new files older than N days
#
#SYNOPSIS
#  rmnew [days]
#
#DESCRIPTION
#
#OPTIONS
#
#EXAMPLES
#
#FILES
#
#BUGS
#
#SEE ALSO
#
#AUTHOR
#  John Chambers <jc@trillian.mit.edu>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #

$| = 1;
($P = $0) =~ s".*/"";	# Our name, minus directories
$V = $ENV{"V_$P"} || 1;	# Verbose/trace/debug level
$exitstat = 0;			# Set to nonzero for failure

$days = shift || 30;

@dirs = `find . -name new`;
for $d (@dirs) {
	$d =~ s/[\r\s]+$//;
	print "Dir:	$d\n" if $V>2;
	@files = `find $d -name '*.abc' -o -name '*.txt'`;
	for $f (@files) {
		$f =~ s/[\r\s]+$//;
		$f =~ s"^\./+"";
		if (($age = -M $f) > $days) {
			printf "%7d	$f\n",$age;
			unlink $f;
		}
	}
}



exit $exitstat;

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
