The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ? Browser_ice AIX 2 06-13-2009 08:39 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
grep to find content in between curly braces, "{" and "}," keshav_rk Shell Programming and Scripting 4 08-09-2007 10:14 PM
why "expr "${REPLY}" : '\([1-9][[:digit:]]*\)" can figure out whether it is a digit? sleepy_11 Shell Programming and Scripting 6 08-08-2007 03:51 AM
Is there any way to show timestamp instead of date in "ls –l" umen Shell Programming and Scripting 1 02-19-2006 01:35 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-25-2009
Browser_ice Browser_ice is offline
Registered User
  
 

Join Date: Nov 2005
Location: Canada
Posts: 110
Question HowTo: reg expr doing grep "timestamp>$DesiredTime" logfile ?

I know I asked a similar question but I want to know if there is a regular expression existing that with a korn shell cmd, finds any timestamp data records in a file where it is greater then a timestamp in a shell variable ?


something like :

grep all records where it has a timestamp > $DesiredTime from logfile-X

It would simplify my coding alot for what I want to do on the client's AIX 4.2
  #2 (permalink)  
Old 07-04-2009
Browser_ice Browser_ice is offline
Registered User
  
 

Join Date: Nov 2005
Location: Canada
Posts: 110
Any ideas ?
  #3 (permalink)  
Old 07-04-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
How does the format of the dates lookes like in your log file?
  #4 (permalink)  
Old 07-05-2009
Browser_ice Browser_ice is offline
Registered User
  
 

Join Date: Nov 2005
Location: Canada
Posts: 110
Quote:
Originally Posted by Franklin52 View Post
How does the format of the dates lookes like in your log file?
like the standard `date` output:

I know I could always do a regular expression to match each date parts. But I need to know if there a special one that will allow me something like :
grep all records in file where any timestamp in it is > $a_given_timestamp
  #5 (permalink)  
Old 07-05-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,382
Quote:
Originally Posted by Browser_ice View Post
like the standard `date` output:

I know I could always do a regular expression to match each date parts. But I need to know if there a special one that will allow me something like :
grep all records in file where any timestamp in it is > $a_given_timestamp
For that I afraid you have to convert your timestamp to min or sec's before comapring it with the given timestamp(that should be also in min or in sec's)
  #6 (permalink)  
Old 07-05-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
To match dates you can use a format like YYYYMMDDHH, an example to convert the date format Mar 17 16:44:03 2009 to 2009031716

Code:
echo "Mar 17 16:44:03 2009"|
awk -F" |:" '
BEGIN {
  a="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
  split(a,m,",")
  for(i=1;i<13;i++)
    n[m[i]]=i
}
{printf("%s%02d%02d%s\n", $6, n[$1], $2, $3)}
'
Use nawk or /usr/xpg4/bin/awk on Solaris if you get errors.
Sponsored Links
Reply

Bookmarks

Tags
grep, regular expression, timestamp

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 05:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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