![두 문자열 사이의 텍스트 줄 읽기](https://linux55.com/image/101837/%EB%91%90%20%EB%AC%B8%EC%9E%90%EC%97%B4%20%EC%82%AC%EC%9D%B4%EC%9D%98%20%ED%85%8D%EC%8A%A4%ED%8A%B8%20%EC%A4%84%20%EC%9D%BD%EA%B8%B0.png)
저는 LaTeX를 사용하여 문제와 전자 공학 흐름에 관한 작은 교과서를 쓰고 있습니다. 각 장에는 작은 파일의 긴 목록이 있습니다. 여기서 각 질문은 LaTeX 환경 질문으로 구분됩니다. 문제에는 설명, 정리, 예가 산재해 있습니다.
이 경우 내 질문은 \begin{Prob} 및 \end{Prob} 문자열 사이의 모든 줄(이 두 줄 포함)을 추출하는 방법입니다.
\section{Vector Operations}
\begin{description}[style=multiline,leftmargin=0.25\textwidth,font=\bfseries]
\item [Negative Direction] If $\vb{A}$ is defined as shown
\item [Addition] Adding $\vb{A}$ and $\vb{B}$ is done by
\end{description}
\section{Exercises}
\begin{Prob}
Find the component of $\vb{A}$ along $\vb{B}$ in the following $\vb{A}= 10\ux-6\uy+7\uz$ and $\vb{A}= -5\ux+7\uy$ and find $3\vb{A}+2\vb{B}$.
\begin{ans}
content...
\end{ans}
\begin{sol}
The component of $\vb{A}$ along $\vb{B}$ is found by
$(\vb{A}\dotproduct \vb{B}) \frac{\vb{B}}{\abs{B}} $
and, $\vb{A}\dotproduct \vb{B} = A_xB_x+A_yB_y+A_zB_z$
If $\vb{A}= 10\ux-6\uy+7\uz$ and $\vb{A}= -5\ux+7\uy$ then $\vb{A}\dotproduct \vb{B} = 10(-5)-6.7$
\end{sol}
\end{Prob}
\begin{Prob}
Given that $L(2,3,2)$ and $M(-3,0,5)$ find
\begin{enumerate}[noitemsep,nolistsep]
\item Vector directed from Origin to $L$.
\item Unit vector along from origin to the mid point of $L$ and $M$.
\item Calculate the length of vector $\boldsymbol{LM}$.
\end{enumerate}
\begin{ans}
\begin{multicols}{3}
\begin{enumerate}[noitemsep,nolistsep]
\item $\vecty{2}{3}{2}$
\item $\big( -0.5, 1.5, 3.5 \big) $
\item $\vecty{2.5}{1.5}{-1.5}$
\end{enumerate}
\end{multicols}
\end{ans}
\begin{sol}
\begin{enumerate}[noitemsep,nolistsep]
\item \begin{align*}
\boldsymbol{LO} &= \vecty{(2-0)}{(3-0)}{(2-0)}\\
&= \vecty{2}{3}{2} \\
\end{align*}
\item Mid point of $L$ and $M$ \begin{align*}
\boldsymbol{ML} &= \Big(\frac{(2-3)}{2}, \frac{(3+0)}{2}, \frac{(2+5)}{2} \Big) \\
&= \big( -0.5, 1.5, 3.5 \big) \\
\end{align*}
\item Vector joining $L$ and $M$ is \begin{align*}
\boldsymbol{LM} &= \vecty{\frac{(2+3)}{2}}{\frac{(3-0)}{2}}{\frac{(2-5)}{2}} \\
&= \vecty{2.5}{1.5}{-1.5}
\end{align*}
\end{enumerate}
\end{sol}
\end{Prob}
줄 추출을 위한 bash 스크립트를 제안해 주세요. Python과 같은 다른 솔루션도 환영합니다.
답변1
"풀"이 "인쇄"를 의미한다고 가정하면 가장 간단한 접근 방식은 다음과 같습니다.
sed -n '/\\begin{Prob}/,/\\end{Prob}/p' myfile