[PLUG] Selectively delete files

Nathan Meyers nmeyers at javalinux.net
Wed Mar 27 21:11:11 UTC 2002


On Wed, Mar 27, 2002 at 01:01:07PM -0800, Michael Montagne wrote:
> I need to do some cleanup of my FTP site.  The idea is to delete all
> files that haven't been modified in the last 90 days.
> So something like this seems to work:
> find /home/ftp -type f -mtime +90 -print0|xargs -0 rm
> However there are certain directories that contain files that should never be deleted.
> How can I incorporate a text file with a listing of directories that are
> immune to file removal and evaluate my list of files against that list?
> Or exclude those directories from the find?
> Using file globbing wildcards would be nice too.

At the risk of being labeled a Perl zealot :-)... this could be done
with a pretty short Perl script. You can build a basic search script by
using Perl's find converter:

    find2perl /home/ftp -type f -mtime +90 -print0

and then modifying the resulting wanted() subroutine to add a check
against a hash that names files you don't want to touch.

Of course, you can also delete files in the script.

Nathan




More information about the PLUG mailing list