Você pode usar apenas find
:
find . -type f -size 0 -exec echo "The logfile has a 0 size: {}" \;
find . -type f ! -size 0 -exec echo "The logfile does not have a 0 size: {}" \;
Ou perl
:
#!/usr/bin/perl --
use File::Find;
# directory to start looking for log files
my $dir = '/tmp/a';
# search base directory and call subroutine for each file found
find(\&size_check, $dir);
# subroutine to be called by find
sub size_check{
# check filename matches regex and is a file (not directory)
if($_ =~ /^.*\.log$/ and -f $_){
# call stat and put data into an array
my @stat = stat($_);
# check to see if the size is zero
if($stat[7] == 0){
print $_ . " has a size of 0\n";
}else{
print $_ . " has a " . $stat[7] . " size\n";
}
}
}