![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Knowing the half will get you into trouble - describe your disasters | benefactr | What's on Your Mind? | 3 | 04-25-2008 12:48 PM |
| Output number of rows inserted, updated... | kushal_cog | UNIX for Dummies Questions & Answers | 0 | 01-30-2008 03:28 AM |
| to extarct data points | cdfd123 | Shell Programming and Scripting | 5 | 01-12-2008 09:39 AM |
| Urgent...FTP unable finish download file, hang half way | foongkt5220 | SUN Solaris | 3 | 08-11-2006 07:31 AM |
| Extarct specific records from wide file | acheepi | Shell Programming and Scripting | 1 | 10-02-2005 01:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How can i extarct the output from a file which has been updated from last half an hou
hi,
I have a log file , which is appending with current data i need the extarct which is updated from last 30 minutes the format of the date is Jun 18, 2008 8:59:18 AM how can i subtract 30 mins from the current date thanks Tarun. |
|
||||
|
one way
Code:
#!/bin/ksh
# filetimes
minsago()
{
perl -e '
use POSIX qw(strftime);
$fmt="%c"; # change this to meet your needs
$now=time;
$now-=1800; # 30 minutes = 1800 seconds
($sec,$min,$hour,$day,$mon,$yr,$wday,$yday,$dntcare)=localtime($now);
$result=strftime($fmt, $sec,$min,$hour,$day,$mon,$yr,$wday,$yday,$dntcare);
print "$result"
' $1
}
start=$(minsago)
echo "$start"
|
|
||||
|
With gnu coreutils date:
Code:
DTE=$(date "+%b %d, %Y %r" --date "now -30 minutes") grep "$DTE" your-file Code:
LC_ALL=C DTE=$(date "+%b %d, %Y %r" --date "now -30 minutes") grep "$DTE" your-file |
|
||||
|
Hi Ripat
Thanks for the reply, but it does not solve my purpose, it is just changing the format of the date but not subtracting 30 mins $ DTE=$(date "+%b %d, %Y %r" --date "now -30 minutes") $ echo $DTE Jun 23, 2008 02:43:34 AM $ date Mon Jun 23 02:43:49 EDT 2008 i have a log file i need to extract data which has been updated from last 30 mins plz advise |
![]() |
| Bookmarks |
| Tags |
| linux, solaris |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|