blattamax
asked on
use File::Find::Node
I have to use the perl module File::Find::Node in a script which have to do the code in attach
find /files -type f -mtime +10 | grep -v "/storico/" | grep -v "error" | grep -v "body_email" | grep -v "/in/" | grep -v "/out/" | grep -v "/appoggio/" | grep -v "/responsi_doppi/" | grep -v .sh$| grep -v .pl$
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry..that was my browser not giving me scroll bars
ASKER
this is the find command
find /files -type f -mtime +10 | grep -v "/storico/" | grep -v "error" | grep -v "body_email" | grep -v "/in/" | grep -v "/out/" | grep -v "/appoggio/" | grep -v "/responsi_doppi/" | grep -v .sh$| grep -v .pl$
find /files -type f -mtime +10 | grep -v "/storico/" | grep -v "error" | grep -v "body_email" | grep -v "/in/" | grep -v "/out/" | grep -v "/appoggio/" | grep -v "/responsi_doppi/" | grep -v .sh$| grep -v .pl$
The code I posted handles the find and all of the grep parts. It will run faster than the code without the filter (which filters the results), because directories that are filtered out will not be searched. The results are printed to the screen. If you'd like the results somewhere else, let me know.
ASKER
thank u Adam , if i'd have to remove the results?
>> if i'd have to remove the results?
Meaning, you want to delete the files? If so, you can update the found subroutine to delete the files.
Meaning, you want to delete the files? If so, you can update the found subroutine to delete the files.
sub found {
my $node = shift;
my $p=$node->path;
print "$p\n"; #Remove this line if you don't want to print the names of files
unlink($p) or warn "Could not remove '$p': $!\n";
}
Open in new window