0

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.tex

So I do not want to include \begin{document} and \end{document} in the output. How can you having an open interval in the output?

1 Answers1

1

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.tex

or with don-crissti's receipt:

sed '/begin{document}/,/end{document}/!d;//d' data.tex

Other way is start printing after begin in loop till the finish line:

sed -n '/begin{document}/{:;n;/end{document}/!{p;b;};}' data.tex
Costas
  • 14,916