Need a little help developing a ksh script. Have read through Perderabo's datecalc routine and it does not seem to fit the function I am looking for. Basically what I am trying to do is find any file (in a specific directory) that was created within the last five minutes. I am not a programming expert but do have a lot of background. Need a Korn shell example or a Perl example that I can call from ksh. Not a Perl programmer, but can understand the basics.
I am a simple guy and like to keep things simple. What I am currently using is to get the current date in seconds and then subtracting 5 minutes.
SECONDS=`date +%s`
FIVEMINSAGO=`expr $SECONDS - 300`
Now what I need is to convert the datestamp of my files to seconds as well. My file is the cut command from an ls -ltr. See example:
Mar 25 11:35 1658.wulog
Mar 25 12:08 1659.wulog
Mar 25 12:29 1660.wulog
Mar 25 12:38 1661.wulog
Mar 25 15:39 1662.wulog
If I can get the date and time converted to seconds, then all I need to do is see if that conversion is greater than $FIVEMINSAGO. That is the easy part. What I am not sure about is how to easily convert the date/timestamps in the example above. Any slick (easy) solution would be greatly appreciated.