Crafty automatic file deletion?

Root Boy Jim rbj at uunet.UU.NET
Tue Mar 26 16:30:30 AEST 1991


In article <SQUASH.91Mar15194116 at heat.math.ufl.edu> squash at math.ufl.edu (Jonathan King) writes:
>My .logout contain a call to _find to automatically remove files
>satisfying certain criteria.  I would like the file's name to provide
>the criterion.  For example, files
>
>  letter.rm.60.tex
>  c_hack.rm.120.c
>
>would be automatically removed if unmodified for 60 and 120 days.
>  (Of course, I could put the specific numbers "60" and "120" into my
>  call to _find.  I would like this to work, automatically, for all
>  numbers that are valid to, say, the -mtime switch of _find.)
>Can this be done by _find or by some other program?

If you can limit yourself to a small number of days, then try:

	for days in 30 60 90 120; do
		find . -name "*.rm.$days.*" -mtime +$days -print | xargs rm -f
	done

Otherwise, First pick all the files matching this pattern, then process them.

	find ~ -name "*.rm.*.*" -print | maybe-remove

Of course now you have to write the latter program.
A good language to write it in would be perl.
-- 
		[rbj at uunet 1] stty sane
		unknown mode: sane



More information about the Comp.unix.internals mailing list