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

how about sed:

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

should work...

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

durr - my bad - not paying attention - the /'s in the regexp need escaped :slight_smile:

or...

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

Should work...

Yep, it works. Thanks.