Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: How do I delete files based on their timestamp?

by btrott (Parson)
on May 08, 2000 at 21:52 UTC ( #10638=note: print w/replies, xml ) Need Help??


in reply to How do I delete files based on their timestamp?

Are you on a *nix system? Using find is probably the easiest way:
find /foo/bar -mtime +7 -exec rm -rf {} \;
This will find all files under /foo/bar that were modified more than 7 days ago and remove them.

If you're *nix-impaired :) (and considering that this is a Perl site), use File::Find:

use File::Find; find(\&wanted, '/foo/bar'); sub wanted { unlink $_ if -M $_ > 7; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://10638]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2021-05-15 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?