1

I have an application that appends to the same log file. As this file is rather large (around 8 gb), I'd like to extract portions based on the timestamp at the beginning of the line.

-bash-3.2$ cat application.log | egrep --color "Starting Application|Exception"
08:46:01.328 [main] INFO  Starting Application...
09:14:53.670 [Thread-1] ERROR Resolver - Caught exception -> com.jgoodie.AuthzException: Authorization failed
Caused by: com.jgoodie.AuthzException: Authorization failed
09:56:15.739 [main] INFO  Starting Application...
10:17:08.932 [Thread-1] ERROR Resolver - Caught exception -> com.jgoodie.AuthzException: Authorization failed
Caused by: com.jgoodie.AuthzException: Authorization failed

In the above example, I'd like to extract the logs for the first run of the application (between 08:46:01.328 and 09:56:15.739). Is there any simple way (preferably a one liner) to do this?

Thanks

qwerty
  • 3,801
  • 2
  • 28
  • 43

2 Answers2

8
sed -n '/08:46:01.328/,/09:56:15.739/p' application.log
Fredrik Pihl
  • 44,604
  • 7
  • 83
  • 130
2
perl -lne 'if(/^08:46:01.328/.../^09:56:15.739/){print}' your_file
Vijay
  • 65,327
  • 90
  • 227
  • 319