Re: Perl: "find -newer" in nativ

Hilmar Preuße <[email protected]>
Newsgroups gmane.user-groups.linux.dresden
Message-ID <[email protected]>
Am 11.02.2023 um 16:36 teilte Andreas Fett mit:

Moin,

> Den Match für den Filenamen bekommste selber hin :-)
>
Habe mich schwer getan, aber ich denke ich habs. Bin halt kein
Programmierer. Hier nur der Teil, den ich geändert habe.

my $touchfile = '/var/log/icinga/Log_stamp';
my $touchstat = stat($touchfile) or die "No $touchfile: $!";
my $filePattern = 'Name_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_.*\.log$' ;
my @files = ();

my $wanted = sub {
         my $stat = stat($_);
         return unless -f $stat;
         return unless $stat->mtime > $touchstat->mtime;
         return unless /$filePattern/;
         push @files, $File::Find::name;
};

find($wanted, glob("/var/log/icinga/logs"));

Danke,
   Hilmar
--
sigfault
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.