Apr 27, 2012

Another way to delete old files in perl

Note: 
1) Please remove comment (#)
2) 'unlink' is the command used to remove file in Unix
 
#!perl
foreach my $file (</path/to/logs/*.log>) {
  next unless -M $file > 7;
  print "Deleting the File $file...\n";
  # unlink $file or die "Failed to remove file $file: $!";
}
-->

No comments:

Post a Comment