Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

RE: RE (tilly) 1: Find files older than x days and delete them

by merlyn (Sage)
on Aug 22, 2000 at 01:32 UTC ( #28921=note: print w/replies, xml ) Need Help??

in reply to RE (tilly) 1: Find files older than x days and delete them
in thread Find files older than x days and delete them

Or even:
# one time: $ find2perl /some/dir -atime +14 -print -eval unlink >MyScript $ chmod +x MyScript # as needed: $ ./MyScript

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
(atl: plain heresy) RE: RE: RE (tilly) 1: Find files older than x days and delete them
by atl (Pilgrim) on Aug 22, 2000 at 15:52 UTC
    I know this is plain, flat heresy, especially here inside the monastry, but why use perl for this at all?
    find /your/path -mtime numberofdays -exec rm -f {} \;
    Father, forgive me, for I have sinned ... ;-))



    Once again I am humbly admitting that merlyn and tilly made good points (see below). So now we have three chief reasons (weapons) for a perl solution:

    After this confession, shall I be free? Hey, stick away from that comfy chair ...
    (do you know that feeling when you should do your already late travel and time reports for your company but keep lurking around instead? Oh boy ...)
      Portability? :-)
      I use it b/c there are several file types that I'm looking for, and I need a log. Windows Find doesn't log, and I'm not sure that you can search out multiple file types. Plus, I'm lazy. I like one click.
        Actually, you can do both.

        To search for multiple file types, type something like '*.bat;*.html' in the search box.

        To save the search critera, click File|Save Search. To save the results of the search, make sure that Options|Save Results is checked, then click File|Save Search.

        There may be a way to save the results as a text file, but I'm not aware of it. I usually just cut'n'paste if I need something like that.


        e-mail jcwren

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2023-01-29 22:01 GMT
Find Nodes?
    Voting Booth?

    No recent polls found