Bash Grep 日志文件中 2 个日期之间的行

3 linux bash shell

我有一个如下所示的日志文件:

2015-07-07 11:23:33,006 DEBUG : Invoking handleMessage on interceptor org.apache.cxf.interceptor.LoggingInInterceptor@2798240a

name="New Test User"
domicile="A Place"
name="Test User"

2015-07-07 15:00:33,008 DEBUG : Invoking handleMessage on interceptor org.apache.cxf.interceptor.
Run Code Online (Sandbox Code Playgroud)

现在我用这样的参数调用我的 bash 脚本:

./test.sh -t 2015-07-07,11:00-2015-07-08,20:00.
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:如果我使用像 2015-07-07 11:00 到 2015-07-08 20:00 这样的时间范围,如何获取日志文件中两个日期之间的文本?

谢谢

小智 6

sed -n "/2015-07-07 11:23:33/,/2015-07-07 15:00:33/p"
Run Code Online (Sandbox Code Playgroud)

或更一般:

sed -n "/$START/,/$END/p"
Run Code Online (Sandbox Code Playgroud)