![]() |
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 |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
Quote:
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 |
|
||||
|
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)}
'
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| grep, regular expression, timestamp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|