I am trying to extract set of lines between specific patterns in bash.
My input file:
=========
a
b
ven
c
d
=========
abc
def
venkata
sad
dada
=========
I am trying to extract only the lines between two =======
which contains the pattern venkata
in between. ie., the second section in the above eg (abc ... dada).
I have tried sed
, but it does not give what I need exactly.
I tried splitting this task to getting lines above venkata
and the lines below it separately.
Using sed -n -e '/=====/,/venkata/p'
gives starting from the beginning of the input, which is not what I need.
Any thoughts ?
Edit: The number of lines between =======
can be of any number and venkata
can be at any line, not necessarily the exact middle.
There can be multiple words,numbers,symbols in each line. This is just a sample
Edit 2: How to select lines between two marker patterns which may occur multiple times with awk/sed accepted answer is close, but gives the output from the first match. That is not what I am looking for.
Based on the command in the answer of that question, it would set the flag when the first ====
is found.
I need the ====
just before venkata
, which need not be the very first match.
That answer does not help me solve my problem