Figuring up dates - age
- I have a problem I'd love some advice on please oh wise ones!
I have many files, each file has many (records) lines with dates in
them - in the form of ccyyddmm - what I have done to give me an
indication as to how old these lines are is said in a shell script is
to first cut out the datefield from each file, look for a date, and
count it - and then tell me how many for each month. Like this:
cut -c131-140 FILENAME | grep 200011* | wc -l
echo "Records were found for November 2000"
cut -c131-140 FILENAME | grep 200012* | wc -l
echo "Record were found for December 2000"
Now as you can see that'll do it - but what I would LIKE to do is
be able to produce an output of:
"437 records are older than 30 days"
"937 records are older than 60 days"
"23 records are older than 90 days"
Now - using the "cut" command to pull the date out - I figure
perhaps I can do something cool with it and PERL based on the current
date - so I figure I can start out by using:
and then SOMEHOW - this is the catcher for me - subtract the record
date from the current date and "know" how many days old a file is.
Can anyone give me any pointers? Do you think there's something in
PERL I could use to do this??
Thanks in advance!