The -M operator returns the age in days wrt the script start time, so what you want can be as simple as this:
I could have set $max_age to numerical 5, but I like having the unit for self-documentation. As long as the numerals are first in the string, Perl does what I want.my $dir = '/path/to'; my $max_age = '5 days'; for (<$dir/*>) { -M > $max_age and print "I would have deleted $_.\n"; }
After Compline,
Zaxo
In reply to Re: Compare mtime?
by Zaxo
in thread Compare mtime?
by mbeason
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |