Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uwm.edu!linac!att!bellcore!uunet!rbj From: rbj@uunet.UU.NET (Root Boy Jim) Newsgroups: comp.unix.internals Subject: Re: Crafty automatic file deletion? Message-ID: <126507@uunet.UU.NET> Date: 26 Mar 91 06:30:30 GMT References: Organization: UUNET Communications Services, Falls Church, VA Lines: 29 In article squash@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@uunet 1] stty sane unknown mode: sane