Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: use file::find to find files modified in last 5 days

by wwe (Friar)
on Feb 22, 2012 at 12:42 UTC ( #955510=note: print w/ replies, xml ) Need Help??


in reply to use file::find to find files modified in last 5 days

The docs of File::Find show this example:

find2perl / -name .nfs\* -mtime +7 \ -exec rm -f {} \; -o -fstype nfs -prune
produces something like:
sub wanted { /^\.nfs.*\z/s && (($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_)) && int(-M _) > 7 && unlink($_) || ($nlink || (($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_ +))) && $dev < 0 && ($File::Find::prune = 1); }
what's wrong with it?


Comment on Re: use file::find to find files modified in last 5 days
Select or Download Code
Re^2: use file::find to find files modified in last 5 days
by bart (Canon) on Feb 22, 2012 at 12:49 UTC
    what's wrong with it?
    What's wrong? How about: completely incomprehensible to anybody but Unix gurus.

      True, it's complicated. But a few minutes spent looking at the man page for find2perl and the POD for File::Find should permit a user to piece things together.

      It's not always necessary to understand *everything* about a subject in order to make use of the tools. I don't know how to tear apart and rebuild my car's engine, but that doesn't prevent me from driving it.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re^2: use file::find to find files modified in last 5 days
by mikesolomon (Novice) on Feb 22, 2012 at 12:54 UTC

    I had looked at that but couldn't work out how to integrate it into my script

      As brother thargas has explained, you need to look at the documentation. Type perldoc File::Find and you'll be presented with an example in the Synopsis section that should answer your question:

      use File::Find; find(\&wanted, @directories_to_search); sub wanted { ... }
      You pass File::Find::find two parameters: a reference to a function that will be called when a matching file is found, and a list of directories to be searched. And it should Just Work(tm).

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2014-09-19 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls