Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sed 我想从一个tex文件中提取pspictures并将其放入另一个文件中,这样它们就可以很容易地处理成ps或pdf文件_Sed_File Processing - Fatal编程技术网

Sed 我想从一个tex文件中提取pspictures并将其放入另一个文件中,这样它们就可以很容易地处理成ps或pdf文件

Sed 我想从一个tex文件中提取pspictures并将其放入另一个文件中,这样它们就可以很容易地处理成ps或pdf文件,sed,file-processing,Sed,File Processing,我有一个文件列表.tex文件,其中包含构建ps图片的tex中的片段,这些图片的处理速度可能较慢 多个文件中有多个片段,结尾分隔符为\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

我有一个文件列表.tex文件,其中包含构建ps图片的tex中的片段,这些图片的处理速度可能较慢

多个文件中有多个片段,结尾分隔符为
\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}
我想提取碎片

我不知道该怎么办?
awk
可以这样做还是
sed

它们似乎一行一行地工作,而不是在整个片段上工作

我不是真的在寻找一个解决方案,只是一个好的候选工具

sed -En '/^\\begin\{pspicture\}.*$/,/^\\end\{pspicture\}.*$/p' file
对正则表达式使用带-E的sed


使用//、//确定正则表达式的开头和结尾,并从头到尾打印所有行。

欢迎使用12年后的堆栈溢出。请在问题中添加您自己的代码。你至少要展示你自己为解决这个问题所做的研究。