我需要一个用于将 TeX
上传到在线 shell 的文档。我不希望 shell 对内容做任何事情。以下 MWE 是我迄今为止管理过的最好的。
cat << EOF > /tmp/mytex
\documentclass{article}
\begin{document}
Test mathematics: $ 2^{10} = 1024$ works but
$e^{i\pi} = -1$ is mangled because no space follows the $e$.
"double" and 'single' quotes should be preserved too.
\end{document}
EOF
最佳答案
试试这个:
cat << 'EOF' > /tmp/mytex
\documentclass{article}
\begin{document}
Test mathematics: $ 2^{10} = 1024$ works but
$e^{i\pi} = -1$ is mangled because no space follows the $e$.
"double" and 'single' quotes should be preserved too.
\end{document}
EOF
From the bash reference manual :
The format of here-documents is:
<<[-]word
here-document
delimiter
If any characters in word are quoted, the delimiter is the result of quote removal on word, and the lines in the here-document are not expanded.
关于bash - 禁用 shell 解析的 here-document,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15329323/