Pull log between two dates.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pull log between two dates.
# 1  
Old 11-12-2009
Pull log between two dates.

Hi,

I am trying to pull out lines from logs between two dates, the logs has lines like this :

[12/Nov/2009:10:45:16 -0500] conn=552 op=3 msgId=17228 - RESULT err=0 tag=97 nentries=0 etime=0 dn="cn=amldapuser,ou=dsame u
sers,dc=abc,dc=com"
[12/Nov/2009:10:45:16 -0500] conn=553 op=-1 msgId=-1 - fd=34 slot=34 LDAP connection from 52.99.164.14 to 52.99.166.5


The command i amd trying to run is following, i'm using nawk because OS is solaris:

nawk '$0>=from&&$0<=to' from="12/Nov/2009:09:29" to="12/Nov/2009:10:45" access

This is not giving me any output.

Thanks, John
# 2  
Old 11-12-2009
how about sed:

Code:
sed -n '/12/Nov/2009:09:29/,/12/Nov/2009:10:45/p' file

should work...
# 3  
Old 11-12-2009
Nope.

bash-2.05$ sed -n '/12/Nov/2009:09:29/,/12/Nov/2009:10:45/p' access
sed: command garbled: /12/Nov/2009:09:29/,/12/Nov/2009:10:45/p

Thanks, John
# 4  
Old 11-12-2009
durr - my bad - not paying attention - the /'s in the regexp need escaped :-)

or...

Code:
#  sed -n '/12.Nov.2009:10:45:16/,/12.Nov.2009:10:45:16/p' infile

Should work...
# 5  
Old 11-12-2009
Yep, it works. Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grepping only dates from a log file

Hi All, I have a log file where every line contains a date and some other data, i want to grep only the date from every line to a different file. Please help how to get this. Thanks in advance !! (25 Replies)
Discussion started by: nanz143
25 Replies

2. Shell Programming and Scripting

Access log field - using awk to pull date/time

hey guys. the following line is a line taken from apache's access_log 10.10.10.10 - jdoe "GET /images/down.gif HTTP/1.1" 304 I'm concerned about the field that has the date and time in it. if assuming the delimiter in the file is a space, then the fourth field will always have the date... (5 Replies)
Discussion started by: SkySmart
5 Replies

3. Shell Programming and Scripting

pull range of dates/times and put into new file

Need to pull from a range of dates/times (ex. 6:00 AM March 3 through 6:00 AM March 4) from a folder and put those file names in a new file to process later. Dates would not be hard dates but dates from the folder directory, how would I do that? (9 Replies)
Discussion started by: freddie999
9 Replies

4. Shell Programming and Scripting

Archive log Pull script from one server to another server

Hi all, Iam looking out for a shell script which pulls archive from Server A to Server B. And at the same time, we dont want the archives which are already pulled in Server B to be removed from Server A. Please help me on this, I have been trying on this for a quiet few time. ... (3 Replies)
Discussion started by: vivi.raghav
3 Replies

5. Shell Programming and Scripting

Need script to pull multiple field from log file

I am hoping to get some help with a script to pull certain fields from a log file. User update (xx6xxx P) rpt (yy6yyy B) 2010/01/20 21:36:01.298 Remote client forward start streamid 85af 2010/01/20 21:36:01.307 rpt2 (ZZ6ZZZ G) rpt1 (YY6YYY B) urcall (CQCQCQ ) mycall (W1AW) user... (5 Replies)
Discussion started by: TedSD
5 Replies

6. Shell Programming and Scripting

Need script to generate all the dates in DDMMYY format between 2 dates

Hello friends, I am looking for a script or method that can display all the dates between any 2 given dates. Input: Date 1 290109 Date 2 010209 Output: 300109 310109 Please help me. Thanks. :):confused: (2 Replies)
Discussion started by: frozensmilz
2 Replies

7. Shell Programming and Scripting

Getting list of all the log files between two dates

I need to get the list of all the log files for a particular duration, say between two dates,i.e I need to get the list of all the log files between date1 and date2.The two dates are entered by the user. The format of the log file is : /path_name/graph_name_20080801180308.log. I dont... (1 Reply)
Discussion started by: avishekp
1 Replies

8. Shell Programming and Scripting

find log file between two dates

Dear All, Please can you help me to crack this query? If the log files for the task above all had a naming convention of myoutput_YearMonthDay.log (i.e. myoutput_20060215) How would you find only those log files created between the 10th and the 20th of each month going back the last 365 days.... (1 Reply)
Discussion started by: justin_mca
1 Replies

9. Shell Programming and Scripting

grep a log file between 2 dates

Hi Currently I can grep a log file with the following command: $results = `grep -A 2 '^$date.$time.*' $log`; and the following arguments: $date = 2007/04/25 $time = 16:07 Log example: 2007/04/25 16:07:12.145701 2007/05/25 14:07:12.145701 2007/05/25 17:07:12.145701 2007/06/25... (37 Replies)
Discussion started by: Epiphone
37 Replies

10. Shell Programming and Scripting

help searching log file with dates

Im tyring to create a script that will show me any lines in a file with todays date and yesterdays, the date format in the file is as follows ----- amqxfdcx.c : 728 -------------------------------------------------------- 07/12/05 09:53:20 AMQ6109: An internal WebSphere MQ error has... (3 Replies)
Discussion started by: csaunders
3 Replies
Login or Register to Ask a Question