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

Greetings RichardK, and thank you for your reply.
Yes. This is exactly the sort of return I had anticipated (as you provided).
With the exceprion of:

file->name('*.iso')
which should have read:
file->name('*.xz')
as ./iso/ was a reference I used to a directory.
As to find(1); -cmin refers to:
-cmin n True if the difference between the time of last change of file status information and the time find was started, rounded up to the next full minute, is n minutes.
referring to *BSD UNIX' version of FIND(1).

Which is actually the most important part of my reason for trying this;
I need to clobber (perldoc -f unlink) symlinks (perldoc -f symlink) older than 11 minutes. Unfortunately, Perls find2perl only provides:

-atime N True if last-access time of file matches N (measured in days) (see bel +ow). -ctime N True if last-changed time of file's inode matches N (measured in days, + see below). -mtime N True if last-modified time of file matches N (measured in days, see be +low). -newer FILE True if last-modified time of file matches N. # # # See below: # # # 1. * N is prefixed with a +: match values greater than N 2. * N is prefixed with a -: match values less than N 3. * N is not prefixed with either + or -: match only values equal t +o N
NOTE: (measured in days, see below), which is different than the find the system provides.
As the system' find provides minutes. While I'm sure it must be possible to feed the string some math to make it more granular, I'm not clever enough to figure out how. :(

Thank you again, for taking the time to respond.

--chris

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


Comment on Re^2: File::Find seems grossly inefficient for performing simple file tasks
Select or Download Code
Re^3: File::Find seems grossly inefficient for performing simple file tasks
by RichardK (Priest) on Apr 26, 2013 at 15:19 UTC

    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.

      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.

      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.