grep a range of time & date

how can i grep a range?
i have a text file with the following text:

result.log.00:2012/01/02 12:00:07.422    LOG STARTED HERE
  N6Kashya29MemoryShieldScheduler_AO_IMPLE, pid=8662/8658,
config=(alertThreshold=10,alertLevel=0,killThreshold=7200,coreThreshold=0,full=1),
deltaTime=0,
cmd=N6Kashya59MemoryShieldScheduler_AO_IMPL_printStatistics_6_CmdConcreteE
2012/01/02 16:53:18.228 - #0 - 8662/8658 - MemoryShield: errno=0 Assertionresult.log.00:2012/01/02 12:22:36.558  
 result.log.00:2012/01/02 19:39:33.562    LOG STARTED HEREN6Kashya29MemoryShieldScheduler_AO_IMPLE, pid=8662/8658,
result.log.00:2012/01/03 12:00:08.444   LOG STARTED  HERE
config=(alertThreshold=10,alertLevel=0,killThreshold=7200,coreThreshold=0,full=1),
deltaTime=0,
cmd=N6Kashya59MemoryShieldScheduler_AO_IMPL_printStatistics_6_CmdConcreteE
2012/01/02 16:53:18.228 - #0 - 8662/8658 - MemoryShield: errno=0 Assertionresult.log.15.gz:2012/01/02 10:13:20.809    

  result.log.00:2012/01/03 12:00:09.333    LOG STARTED HERE

for example grep a range of of 2012/01/02 12:00:07 up to 2012/01/03 12:00:08 will return:

result.log.00:2012/01/02 12:00:07.422    LOG STARTED  HERE
  N6Kashya29MemoryShieldScheduler_AO_IMPLE, pid=8662/8658,
config=(alertThreshold=10,alertLevel=0,killThreshold=7200,coreThreshold=0,full=1),
deltaTime=0,
cmd=N6Kashya59MemoryShieldScheduler_AO_IMPL_printStatistics_6_CmdConcreteE
2012/01/02 16:53:18.228 - #0 - 8662/8658 - MemoryShield: errno=0  Assertionresult.log.00:2012/01/02 12:22:36.558  
 result.log.00:2012/01/02 19:39:33.562    LOG STARTED  HEREN6Kashya29MemoryShieldScheduler_AO_IMPLE, pid=8662/8658,
result.log.00:2012/01/03 12:00:08   LOG STARTED  HERE

thank u for your help.

Hi boaz733,

One way using 'perl':

$ perl -ne 'if ( /2012\/01\/02 12:00:07/ .. /2012\/01\/03 12:00:08/ ) { print }' infile
result.log.00:2012/01/02 12:00:07.422    LOG STARTED HERE
  N6Kashya29MemoryShieldScheduler_AO_IMPLE, pid=8662/8658,
config=(alertThreshold=10,alertLevel=0,killThreshold=7200,coreThreshold=0,full=1),
deltaTime=0,
cmd=N6Kashya59MemoryShieldScheduler_AO_IMPL_printStatistics_6_CmdConcreteE
2012/01/02 16:53:18.228 - #0 - 8662/8658 - MemoryShield: errno=0 Assertionresult.log.00:2012/01/02 12:22:36.558  
 result.log.00:2012/01/02 19:39:33.562    LOG STARTED HEREN6Kashya29MemoryShieldScheduler_AO_IMPLE, pid=8662/8658,
result.log.00:2012/01/03 12:00:08.444   LOG STARTED  HERE

Regards,
Birei

2 Likes