I need a here document for uploading TeX to an online shell. I don't want the shell to do anything with the contents. The following MWE is the best I have managed so far.
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
Try this:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With