I am having the same requirement like mentioned in this thread.i.e to take the lines which are modified within 5 hrs.
Only thing is the timestamp is getting differed like below.
So i modified the script like below,
Please help me on this as am not getting proper output
There are several problems here:
If there is ANY chance that your script could be run close to midnight, NEVER set the starting date and timestamp in separate calls to the date utility.
Using tr to get rid of spaces at the start of the month and day fields in dates is perfectly reasonable, but relatively expensive. Using shell built-ins to handle this issue is much more efficient.
The input to the cut command in this pipeline is standard input for the script (not your log file).
Adding a leading "[" to the date strings is much more efficient than invoking a separate process to run cut to remove the 1st character from each line in your log files.
sed 's/:/ /3'awk is not a valid sed command. I assume that you intended to have sed 's/:/ /3' | awk instead, but when doing string comparisons to compare timestamps, getting rid of the colon and the milliseconds won't affect the results.
Your use of %H (and my use of %T) present the hour as a two digit value with a leading "0" for times before 10am. Your sample input omits the leading "0" and you didn't make any adjustments to account for that. (Note that a leading "0" needs to be added to your input data (when needed); removing a leading "0" (if present) from ts will not correctly check for the desired times.)
If I correctly understand your new input file format, the following might do what you want:
Help
There are so many lines in log file like 'SQL> spool off'
just I want to add one new line after this to seperate
each one
eg;
SQL> spool off
-------------------------------
SQL> spool off
-------------------------------
SQL> spool off
------------------------------- (2 Replies)
I have errors in the log that span multiple lines and I can find say the 2nd line in the log of this error using an unique word. However, this only gets me the line that the word appears in not the full error which may be 3 or four line long. So if there way to display say the line before a match... (4 Replies)
Hi,
I have gps receiver log..its giving readings .like below
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GPSD,R=1
$GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Hi guys, I'm really happy to find this forum
I have a log file, and I have to find all lines that have "error" word, and then save this output in file, the output file has to have just only one line to any Duplicated lines and counter that show how many time this lines duplicated?
I already... (2 Replies)
Hi all:
I'm working on a HPUX 11.23 system and I am needing to parse a tomcat-jakarta log file for memory use. Getting the desired data is easy, assuming the log file does not grow. This file grows constantly and I want to check it q 5 min. The next check will pick up from where it left off 5... (4 Replies)
Greetings, I'm new to this forum, also new to shell script
I have done some simple shell script before, like backup linux machine using rsync and crontab, but now I need to do some log analyzing, which is beyond my ability... so I'm going to seek for help in this forum, hope someone could give... (5 Replies)
I have a LOG file which looks like this
Import started at: Mon Jul 23 02:13:01 EDT 2012
Initialization completed in 2.146 seconds.
--------------------------------------------------------------------------------
--
Import summary for Import item: PolicyInformation... (8 Replies)
Hi,
I want to read a live log file line by line and considering those line which start from time stamp;
Below code I am using, which read line but throws an exception when comparing line that does not contain error code
tail -F /logs/COMMON-ERROR.log | while read myline; do... (2 Replies)
Dear all,Zabbix version : 2.4 (yes, I know, upgrading soon - honest)
Server OS version : CentOS 6, 64-bit (CentOS 7 with the Zabbix upgrade)I've got a large log file that I would like to read by an external process. It's basically the same as reading the item value on a web-page. I have... (5 Replies)