0
我正在嘗試遍歷目錄及其所有子目錄,以查看這些目錄中的文件是否具有一定的大小。但我不確定@files數組中的文件是否仍然包含文件大小,因此我可以比較大小(即 - 大小< = value_size)。有人可以提供任何指導嗎?需要通過目錄及其所有子目錄遍歷以在Perl中查找某個文件
use strict;
use warnings;
use File::Find;
use DateTime;
my @files;
my $dt = DateTime->now;
my $date = $dt->ymd;
my $start_dir = "/apps/trinidad/archive/in/$date";
my $empty_file = 417;
find(\&wanted, $start_dir);
for my $file(@files)
{
if(`ls -ltr | awk '{print $5}'`<= $empty_file)
{
print "The file $file appears to be empty please check within the folder if this is empty"
}
else
return;
}
exit;
sub wanted {
push @files, $File::Find::name unless -d;
return;
}
使用逗號代替'=>'編輯 –
謝謝克里斯我沒有考慮用於檢查大小的-s。這確實使它更清晰得多! – SaintClaire33