Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: File::Find seems grossly inefficient for performing simple file tasks

by RichardK (Priest)
on Apr 26, 2013 at 15:19 UTC ( #1030853=note: print w/ replies, xml ) Need Help??


in reply to Re^2: File::Find seems grossly inefficient for performing simple file tasks
in thread File::Find seems grossly inefficient for performing simple file tasks

I read that find man page too and I'm still not sure exactly what it does!

But, I'd interpret that to mean -cmin 7 is changed exactly 7 minutes ago ( which seems a bit odd ).

Anyway, back to the point :), if you look at stat you'll see that atime,mtime,ctime are in seconds since the epoch and the pod for File::Find::Rule says :-

stat tests The following "stat" based methods are provided: "dev", "in +o", "mode", "nlink", "uid","gid", "rdev", "size", "atime", "mtime", "ctime", "blksize", and "blocks". See "stat" in perlfunc for details. Each of these can take a number of targets, which will foll +ow Number::Compare semantics. $rule->size( 7 ); # exactly 7 $rule->size( ">7Ki" ); # larger than 7 * 1024 * 1024 by +tes $rule->size( ">=7" ) ->size( "<=90" ); # between 7 and 90, inclusive $rule->size( 7, 9, 42 ); # 7, 9 or 42

So, you can write a mtime rule to do whatever you need.

I'm guessing mtime but these things are a specific to your OS and file system so you'll have to play around a bit to see what works for you.


Comment on Re^3: File::Find seems grossly inefficient for performing simple file tasks
Download Code
Re^4: File::Find seems grossly inefficient for performing simple file tasks
by taint (Chaplain) on Apr 26, 2013 at 20:47 UTC
    Greetings RichardK, and thanks for taking the time to respond!
    Yes. I know what you mean. The 7 bit wasn't crystal clear to me, either. :P
    I'm guessing (as my OS is concerned) ctime -- Creation-time, will probably be my best choice of targets. As I'm looking for any symlink with a creation-time more than 11 minutes ago. I suppose I could create something that grabs, and holds "current time", and break out the "minutes" portion, then capture the ctime of those files searched for -- also breaking out the minutes portion; comparing >=11 minutes && rm, or something.
    I don't know. Guess I've got some more reading to do.

    Thanks again for your reply!

    --chris

    #!/usr/bin/perl -Tw
    use perl::always;
    my $perl_version = "5.12.4";
    print $perl_version;

      Really, there's no need to do anything that complex.

      time returns seconds since the epoch so you just need to compare ctime against (time() - N) for whatever N seconds you need.

Re^4: File::Find seems grossly inefficient for performing simple file tasks
by Anonymous Monk on May 29, 2013 at 15:42 UTC

    a bit late but perhaps useful to someone.

    Implicit in the description of the -cmin flag is the *nix find's default "-" and "+" syntax.

    So, you are right that -cmin 7 means files that changed exactly 7 minutes ago. If you want "more than 7 minutes ago" use --cmin +7; "less than 7 minutes ago" use --cmin -7.

    if you want "less than or equal to 7 minutes ago", use --cmin -8.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2014-10-31 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (224 votes), past polls