![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to find a date which is 7 days past when given current date | ladtony | Shell Programming and Scripting | 17 | 04-09-2009 05:06 PM |
| Past date display ( today - N) in shell | rauphelhunter | Shell Programming and Scripting | 0 | 02-20-2009 03:00 AM |
| Get date and time for past 1 hour from current date | spch2o | Shell Programming and Scripting | 5 | 08-29-2008 05:32 AM |
| a simple way of converting a date in seconds to normal date | travian | HP-UX | 2 | 11-23-2006 12:25 PM |
| how to get the milli seconds from date in sun unix | r2b | Shell Programming and Scripting | 1 | 03-28-2005 06:26 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Converting past date to seconds
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. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|