1

我有一个附加到同一个日志文件的应用程序。由于这个文件相当大(大约 8 GB),我想根据行首的时间戳提取部分。

-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

在上面的示例中,我想提取应用程序第一次运行的日志(在 08:46:01.328 和 09:56:15.739 之间)。有什么简单的方法(最好是一个班轮)来做到这一点?

谢谢

4

2 回答 2

7
sed -n '/08:46:01.328/,/09:56:15.739/p' application.log
于 2012-09-18T09:40:35.447 回答
2
perl -lne 'if(/^08:46:01.328/.../^09:56:15.739/){print}' your_file
于 2012-09-18T09:56:31.567 回答