Hi Gurus
I need to collect the logs between two time stamp... The log files 12 hours format (ex- Nov 14, 2013 12:10:16 AM UTC) I tried the below commands but no luck.
awk '$0 >= "Nov 14, 2013 9:40:01" && $0 <= "Nov 14, 2013 9:55:01"' file
sed -n '/Nov 14, 2013 7:58:00 PM UTC/,/Nov 14, 2013 8:10:00 PM UTC/p' file
awk - since its 12 hours format so I'm facing issue "AM, PM" and in case if time stamp (from=9:40" and to=10:00" then I'm not receiving any output
sed - if the error between the two time stamp then its not working.
please help me on this ....
Note : Modifying the log format (time) not possible
By example were x.x contains particular filestamps and text and x.awk is an awk script....
josephgr@oc0887178221 ~]$ cat x.x
one
Nov 14, 2013 9:40:01
foobar
barfoo
Nov 14, 2013 9:55:01
five
[josephgr@oc0887178221 ~]$ cat x.awk
/Nov 14, 2013 9:40:01/ {
print $0
while ( getline != /Nov 14, 2013 9:55:01/ ) {
print $0
}
}
[josephgr@oc0887178221 ~]$ awk -f x.awk x.x
Nov 14, 2013 9:40:01
foobar
barfoo
Thanks for the reply.
can you please help me to understand more on x.awk.
Requirement:
I created the shell script to check the errors from weblogic log files. The script will grep "today date" | egrep 'error1 | error2 | error3' from log files and redirecting to > /home/my-dir/test
then I'm planning to collect past 15 mins log entry from /home/my-dir/test.
since it's 12 hours format so I'm using
# Time stamp
tot=`date "+%r %Z" | sed 's/^0//'`
to=`date "+%b %d, %Y"`
frmt=`date -d "-20 minutes" "+%r %Z" | sed 's/^0//'`
from=`date "+%b %-d, %Y"`
please let me know what I need to update on x.awk
guru's
Any suggestion ? it's bit urgent so need your help on this...
---------- Post updated at 02:41 PM ---------- Previous update was at 12:44 PM ----------
blackrageous
Any suggestion, can you please explain more about x.awk