Display lines between timestamp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Display lines between timestamp
# 1  
Old 07-22-2016
Display lines between timestamp

Hi Gurus,

I have a software which logs event in the log file and it has become to big to search into it.

I want to display all the lines from the log files between
Code:
<Jul 21, 2016 3:30:37 PM BST> to <Jul 21, 2016 3:45:37 PM BST>

that is 15 min data .

Please help


Moderator's Comments:
Mod Comment Use code tags, thanks.

Last edited by zaxxon; 07-22-2016 at 07:44 AM..
# 2  
Old 07-22-2016
What have you tried so far and please post a snippet of the log, 5-6 lines using code tags, thank you.
# 3  
Old 07-22-2016
hI

MY CODE is as below

Code:
 sed -n "/Jul 21, 2016 3:30:37 PM BST>/,/Jul 21, 2016 15:41:33/p" nodemanager.log

but didn't return any data

Sample data as below
Code:
<Jul 22, 2016 11:22:12 AM BST> <INFO> <1265706386:28759:ERR:ORA-06512: at "SYS.DBMS_STATS", line 23818>
<Jul 22, 2016 11:22:12 AM BST> <INFO> <1265706386:28759:ERR:ORA-06512: at "SYS.DBMS_STATS", line 23880>
<Jul 22, 2016 11:22:12 AM BST> <INFO> <1265706386:28759:ERR:ORA-06512: at line 2>
<Jul 22, 2016 11:22:12 AM BST> <INFO> <1265706386:28759:ERR:>
<Jul 22, 2016 11:22:12 AM BST> <INFO> <1265706386:28759:ERR:Failed query text:>
<Jul 22, 2016 11:22:12 AM BST> <INFO> <1265706386:28759:ERR:>
<Jul 22, 2016 11:22:12 AM BST> <INFO> <1265706386:28759:ERR:begin>

# 4  
Old 07-22-2016
Are you sure any of your search patterns will match any of the lines in your file, and correct to a dot? Sure that there's just one single space in front of the 3:30:37? Sure 15:41 exist when the AM/PM notation is used?

BTW, wasn't it possible to post a sample that matches (part of) the code snippet?
# 5  
Old 07-22-2016
The statement is ok and should work if the patterns are part of the input file.
Just to make sure, can you please issue the following two commands:
Code:
grep -c "Jul 21, 2016 3:30:37 PM BST>" nodemanager.log

# and

grep -c "Jul 21, 2016 15:41:33" nodemanager.log

.. and post the numbers you get?
# 6  
Old 07-22-2016
Hi

It is not returning any data form grep

I wanted to to all the lines between time 3:30 to 3:41 because the event occured between those time and can't trace as can't read the log files.
# 7  
Old 07-22-2016
Anything from Jul 21 in there?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep lines between last hour timestamp and current timestamp

So basically I have a log file and each line in this log file starts with a timestamp: MON DD HH:MM:SS SEP 15 07:30:01 I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies

2. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

Hi Friends, I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies

3. UNIX for Dummies Questions & Answers

Display files based on particular file timestamp

Hi, I have requirement to list out files that are created after particular file. ex. I have below files in my directory. I want to display files created after /dirdat/CG1/cg004440 file. ./dirdat/CG1/cg004438 09/07/14 0:44:05 ./dirdat/CG1/cg004439 09/07/14 6:01:48 ... (3 Replies)
Discussion started by: tmalik79
3 Replies

4. Shell Programming and Scripting

Display .bash_history with timestamp using script

Hi would like to ask if there is anyway to display .bash_history with timestamp using shell script? i know that you should use history command with HISTTIMEFORMAT="%d/%m/%y %T " to display it in terminal but it does not work when i use it on shell script. It seem that you can't run history... (1 Reply)
Discussion started by: pikamon
1 Replies

5. UNIX for Advanced & Expert Users

ls -l timestamp display format

The time stamp format using "ls -l" is either mmm dd hh:mm or mmm dd yyyy. For later case, how can I know the hh:mm as well. Thanks. (3 Replies)
Discussion started by: pok.fung
3 Replies

6. Shell Programming and Scripting

concatenate log file lines up to timestamp

Hi, Using sed awk or perl I am trying to do something similar to https://www.unix.com/shell-programming-scripting/105887-sed-awk-concatenate-lines-until-blank-line-2.html but my requirement is slightly different. What I am trying to accomplish is to reformat a logfile such that all lines... (4 Replies)
Discussion started by: AlanC
4 Replies

7. Shell Programming and Scripting

copy lines from log files based on timestamp and sysdate

I am sorry to repost this question. it was not clear, and I had the meeting and didn't response the question on time. I do really need help and appreciate your help very much. I'm looking for a simple shell script that will read lots of audit log file (*.aud) in a log fold every 10 minutes,... (1 Reply)
Discussion started by: percvs88
1 Replies

8. Shell Programming and Scripting

Find files older then today & display with timestamp info

Small query- I want to do some operation on all the files older then today. Before I do that operation, i want to verify if the command works properly or not. Surprisingly, the command below returns me file, which are created today - find /mrk_archive/PG/ftp/incomming/gbs/2008 -type f... (2 Replies)
Discussion started by: kedar.mehta
2 Replies

9. UNIX for Advanced & Expert Users

Copy lines from a log file based on timestamp

how to copy lines from a log file based on timestamp. INFO (RbrProcessFlifoEventSessionEJB.java:processFlight:274) - E_20080521_110754_967: rbrAciInfoObjects listing complete! INFO (RbrPnrProcessEventSessionEJB.java:processFlight:197) - Event Seq: 1647575217; Carrier: UA; Flt#: 0106; Origin:... (1 Reply)
Discussion started by: ranjiadmin
1 Replies

10. UNIX for Dummies Questions & Answers

display the timestamp of a server UNIX

I can't find the command shell UNIX to display the timestamp of the current date. It's not an option of the commande date. (3 Replies)
Discussion started by: nicolas
3 Replies
Login or Register to Ask a Question