How to delete a file in latex code with normal complie tex. I create temporary files and when i finish using them I want to delete them. It not delete by bash or editor. Thankyou!

  • 5
    TeX cannot delete files. You have to use a extension like \write18 to call an external program/shell to delete a file. May 2 '17 at 15:47
  • 2
    Related/duplicate: Deleting external/auxiliary files?
    – Werner
    May 2 '17 at 16:53
  • 2
    I'd be wary of deleting files via shell-escape. Until you're ready to clean up you want them around; e.g., if you are doing cross-referencing or a bibliography deleting the .aux file between runs will not get you what you want. I believe most editors that act as front ends for running TeX also have a clean command (e.g., maybe called Trash AUX Files). May 2 '17 at 17:28
  • 1
    The question sounds like a duplicate of the question Deleting external/auxiliary files that Werner posted, but none of the answers there actually address it. @Schweinebacke can you just post your comment as an answer? This seems like a useful question and answer to have around, for future reference. May 2 '17 at 17:41
  • @ShreevatsaR For an answer I'd need to know the system, the format and eventually the used engine. So: No, I cannot give a real answer. But feel free to do it. May 2 '17 at 18:04

You could use the cool latex automation tool arara to automatically delete the text file after the compilation is finished:

% !TeX program = txs:///arara
% arara: pdflatex
% arara: clean: { files: [ foo.txt ] }



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.