Sorry to edit the question again. I found that I didn't ask my question clearly before.
I asked a question yesterday but I found another problem today /.\
Here is my file:
Time 00:00:01
kkk
lll
ccc
aaa: 88
...
Time 00:00:03
jjj
kkk
lll
ccc
aaa: 89
ooo
bbb
aaa
kkk
lll
ccc
aaa: 90
...
Time 00:00:04
kkk
lll
...
Here is the output I want:
Time 00:00:01
kkk
lll
ccc
aaa: 88
Time 00:00:03
kkk
lll
ccc
aaa: 89
Time 00:00:03
kkk
lll
ccc
aaa: 90
Last time I was looking for one line and the other line above it. This time I am looking for a pattern with multiple lines:
kkk
lll
ccc
aaa: /any thing here/
and a line
Time /any thing here/
From the question I asked yesterday, I tried
awk '/Time/{a=$0}/kkk\nlll\nccc\naaa/{print a"\n"$0}' file
and
perl -ane '$t=$_ if /Time/; print $t,$_ if /kkk\nlll\nccc\naaa/' test2
and
pcregrep.exe -M 'kkk.*(\n|.)lll.*(\n|.)ccc.*(\n|.)*aaa' test2
from this
but they are not working or the output is not what I want.
I found a thread like this which is talking about state machine but it is complex since I have several lines to match.
Any suggestion that can solve this problem easily?