The "hard" way involves creating a set of regular expressions based on the current date/time and range. The "logwatch" utility has a perlmodule for doing exactly this sort of thing. Respond and I'll post more info.
The really hard way is to calculate the timestamp of the file in seconds based on the ls output and compare that to the current time minus 7 days of seconds (7*24*3600). It might not be as hard as I think, but it involves some straight coding (in Perl or awk) and probably lots of debugging.
I cant use the find command as i dont have the acces to the directory. The directory is accessed by ftp. I ftp to the remote machine and get the listing from the directory into this particular file. And then from this file I need to filter out files older than 7 days. So I think only way is to use the file.
In that case the timestamp method might be the way left I guess...
Hi Photon - I have little knowlegde about perl so I cant understand what your script does. I think its opening the directory and taking each file and checking for conditions. But can that be done with the contents of a file?
There may be other wazs, but here's what I'd do. Install "logwatch". Let's say it installs into /usr/share/logwatch. Then make a little perl-script:
#!/usr/bin/perl
use lib "/usr/share/logwatch/lib";
use Logwatch ':dates';
$ENV{"LOGWATCH_DATE_RANGE"}="since -7 days";
my $SearchDate = TimeFilter('%b %d %H:%M');
while (<>) {
print if m/\b$SearchDate\b/o;
}