Example:
a43
test1
abc
cvb
bnm
test2
kfo
I need all lines between test1 and test2. Normal grep does not work in this case. Do you have any
You can do something like this too. Lets say you this file test.txt
with content:
a43
test1
abc
cvb
bnm
test2
kfo
You can do
cat test.txt | grep -A10 test1 | grep -B10 test2
where -A
is to get you n
lines after your match in the file and -B
is to give you n
lines before the match. You just have to make sure that n > number of expected lines between test1 and test2
. Or you can give it large enough to reach EOF.
Result:
test1
abc
cvb
bnm
test2