I have the following in a shell Perl script:
my @LS = `ls -1t /logs/log.csv.*`;
foreach my $line (@LS) {
This works fine if there actually is one or more log.csv.* files.
But if no log file exists I get the error:
ls: cannot access…
Can I somehow suppress this warning as the shell script is a cron script and it is OK if there are no files?
Do it all in Perl, including reverse sort by last modified timestamp:
In this example I also made it so it does “stat” on each file only once.