
以下は で動作しますarticle
:
\documentclass[a4paper]{article}
\title{Foo}
\author{Me}
\begin{document}
\input{|"echo foo bar | grep foo"}
\end{document}
その代わりに\input
、これも機能します:
\immediate\write18{echo foo bar | grep foo > /tmp/test.txt}
\input{/tmp/test.txt}
\immediate\write18{rm /tmp/test.txt}
ただし、これは クラスでは機能しないようですltxguide
(どちらのオプションも)。 2 番目は で\write18
、パイピングがない場合 (つまり のみecho foo bar > /tmp/test.txt
) に機能しますが、最初のものはまったく機能せず、パイピングも機能しません。
クラスと一緒にパイプを使用するにはどうすればよいでしょうかltxguide
?
\input{|"echo foo bar | grep foo"}
およびで発生するエラーltxguide
:
! Undefined control sequence.
\GenericError ...
#4 \errhelp \@err@ ...
l.17 \input{|"echo foo bar | grep foo"}
答え1
このltxguide
クラスは
% Make |...| a synonym for \verb|...|.
\RequirePackage{shortvrb}
\MakeShortVerb{\|}
文書の冒頭に追加するだけです
\DeleteShortVerb{\|}