The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-30-2009
synergy_texas synergy_texas is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0