I know that I can grep lines above and below a certain pattern, such as this.
Now I have a problem, I want to grep a line before a certain pattern, but I don't know how far it is, such as:
Time 00:00:01
kkk
lll
aaa
...
Time 00:00:03
kkk
kkk
kkk
lll
lll
aaa
aaa
...
Time 00:00:04
kkk
lll
...
My target pattern is aaa, and the other pattern is "Time xx:xx:xx" and I want the output like this
Time 00:00:01
aaa
Time 00:00:03
aaa
aaa
or
Time 00:00:01
aaa
Time 00:00:03
aaa
Time 00:00:03
aaa
How can I do this?