1235383292
04:01
0 4 0 1
Enter the seconds to be added
300
300
1235382992
03:56
0 3 5 6
The problem here i m facing is how to grep the data from the file from time 03:56 to 04:01 ??
Below the file content:
Feb 20, 2009 12:59:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: ---------------------------------------------------------------
Feb 20, 2009 03:56:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: ---------------------------------------------------------------
Feb 20, 2009 03:57:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: authType=null
Feb 20, 2009 03:59:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: contentLength=-1
Feb 20, 2009 03:59:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: contentType=text/xml;charset=utf-8
Feb 20, 2009 04:00:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: header=Content-Type=text/xml;charset=utf-8
Feb 20, 2009 04:01:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: header=Transfer-Encoding=chunked
Feb 20, 2009 04:02:51 AM org.apache.catalina.valves.RequestDumperValve invoke
I suggest you download and install the logwatch utilities and also the Perl Date::Manip module from CPAN. Combined, you can enter a date or time range and get back a regular expression which will match exactly and only that time range. You can do it by hand, too, with the perl re like this:
1235390785
06:06
Enter the seconds to be subtracted
7600
7600
1235383185
03:59
0 3
Feb 20, 2009 12:59:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: ---------------------------------------------------------------
What i want:
Feb 20, 2009 03:56:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: ---------------------------------------------------------------
Feb 20, 2009 03:57:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: authType=null
Feb 20, 2009 03:59:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: contentLength=-1
Feb 20, 2009 03:59:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: contentType=text/xml;charset=utf-8
Feb 20, 2009 04:00:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: header=Content-Type=text/xml;charset=utf-8
Feb 20, 2009 04:01:51 AM org.apache.catalina.valves.RequestDumperValve invoke
INFO: header=Transfer-Encoding=chunked
Feb 20, 2009 04:02:51 AM org.apache.catalina.valves.RequestDumperValve invoke
Please spell out "output". OP often refers to "original poster" and other things. Output is just 3 characters longer than "o/p". Please pass this along to all your colleagues. Thank you.
Anyway, in answer to your question, it's not working with awk because you are using single-quotes around the regular expression, and this prevents "$b" from being expanded into what you want. Use double-quotes in this case (though using double quotes in general for awk scripts is a bad idea.)