You might do this by using Org's publishing functions, and setting up one for your project. Take a look in particular at the setting publishing-function
, which allows you to specify an arbitrary elisp function by which an org file within a given project is exported.
The publishing function might do a standard export to latex then run a shell command on the resulting file like this:
(defun publish-latex-and-patch (plist filename pub-dir)
"Export a latex file then patch it by reversing lines"
(let ((outfile
(org-publish-org-to 'latex filename ".tex" plist pub-dir)))
(shell-command (format "tac %s > %s-patched.tex"
outfile
(file-name-sans-extension outfile)))))
And you would then export your file by doing C-c C-e P f
("publish this file"). Obviously replace tac
with your patching command, and exercise hygiene (e.g. escaping) if passing untrusted input to the shell.
There are also many org-export hooks, but they are more designed to modify specify elements within the parse tree during the export process.