How can I save shell output to a variable in LaTeX?
- by Frank
I need to be able to execute a shell command through LaTeX [*] and have the resulting output available for use later on in the form of a LaTeX 'variable' (e.g., via a subsequent \newcommand command). If necessary a temporary file could be used to hold the output, although I would like to avoid this. I have been able to use
\immediate\write18
to invoke a bash command before, but this was only used to write to a temporary file.
[*] I realise that the -shell-escape flag must be set for this to be allowed