I was thinking too complicated the slicing in the How to express variables efficiently for SED?I want to include (a,b), not [a,b] like this don_crissti's command:sed '/begin{document}/,/end{document}/!d;/end{document}/q' data.texSo I do not want to include \begin{document} and \end{document} in the output. How can you having an open interval in the output?
How to SED with open boundaries?
sed
There are many ways to do so. I suppose that is more undestandable (choice interval and remove which you don't like to include:sed '/begin{document}/,/end{document}/!d;/begin{document}/d;/end{document}/d' data.texor with don-crissti's receipt:sed '/begin{document}/,/end{document}/!d;//d' data.texOther way is start printing after begin in loop till the finish line:sed -n '/begin{document}/{:;n;/end{document}/!{p;b;};}' data.tex