i have a text file which looks like this:
random useless text
para1
para2
para3
random us
No need for head and tail or grep or to read the file multiple times:
sed -n '//{:a;n;//b;p;ba}' inputfile
Explanation:
-n - don't do an implicit print//{ - if the starting marker is found, then
:a - label "a"
n - read the next line//q - if it's the ending marker, quitp - otherwise, print the lineba - branch to label "a"} end if