[comp.unix.wizards] Crafty automatic file deletion?

squash@math.ufl.edu (Jonathan King) (03/16/91)

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?

Thank you.
Jonathan  squash@math.ufl.edu

jik@athena.mit.edu (Jonathan I. Kamens) (03/18/91)

  (I have cross-posted this response to comp.unix.questions, and directed
Followups there.  I don't really see any reason to consider this a
wizard-level discussion.)

In article <SQUASH.91Mar15194116@heat.math.ufl.edu>, squash@math.ufl.edu (Jonathan King) writes:
|> [Asks if there's any utility that can parse a filename and figure out from
|>  it when to delete it.]

  The only way find is going to be able to do this is if you give it explicit
arguments for each number you want to check for; this doesn't seem to be what
you want to do.

  In general, the utilities that can do string manipulation understand nothing
at all about file modification times, and the utilities that understand mtimes
don't understand how to do any string manipulation, so you'll have to use
multiple processes to get anything approaching the functionality you're trying
to achieve, unless you write your own C program to do it.

  Or, you could use perl.  Perl can do the recursive file search, it can parse
the filenames in order to extract from them a number to check against, and it
can stat the file in order to get the modification time.  All this in one
process.

  No, I'm not going to volunteer a perl script to do this.  I'm not enough of
a perl guru to be able to throw one together in five minutes.  I'm sure
Randall or Tom or Larry will jump right in and suggest something. :-)

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710