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
To make it more deterministic and not having to worry about size of file, use the wc -l and cut the output.
grep -Awc -l test.txt|cut -d" " -f1
test1 test.txt | grep -Bwc -l test.txt|cut -d" " -f1
test2
To make it easier to read, assign it to a variable first.
fsize=wc -l test.txt|cut -d" " -f1
; grep -A$fsize test1 test.txt | grep -B$fsize test2