-1

I have a list of files .tex file that contain fragments in the tex that build ps pictures which can be slow to process.

There are multiple fragments across multiple files and the end delimiter is \end{pspicture}

% this is the beginning of the fragment
\begin{pspicture}(0,0)(23,5)
\rput{0}(0,3){\crdKs}
\rput(1,3){\crdtres}
\rput(5,3){\crdAh}
\rput(6,3){\crdKh}
\rput(7,3){\crdsixh}
\rput(8,3){\crdtreh}
\rput(12,3){\crdQd}
\rput(13,3){\crdeigd}
\rput(14,3){\crdsixd}
\rput(15,3){\crdfived}
\rput(16,3){\crdtwod}
\rput(20,3){\crdKc}
\rput(21,3){\crdfourc}
\end{pspicture}

I would like to extract the fragments.

I am not sure how to go about this? can awk do this or sed?

They seem to work line by line, rather than work on the whole fragment.

I am not really looking for a solution just a good candidate tool.

  • 1
    Welcome to Stack Overflow after 12 years. [SO is a question and answer page for professional and enthusiast programmers](https://stackoverflow.com/tour). Please add your own code to your question. You are expected to show at least the amount of research you have put into solving this question yourself. – Cyrus Nov 22 '20 at 22:04

1 Answers1

2
sed -En '/^\\begin\{pspicture\}.*$/,/^\\end\{pspicture\}.*$/p' file

Utilising sed with -E for regular expressions.

Use //,// to determine start and ending regular expressions and print all lines from the start to the end.

Raman Sailopal
  • 12,320
  • 2
  • 11
  • 18