Is there a command to delete all auxiliary files within the terminal without compiling the tex-file first?

There is such an option for latexmk but then I have to build the pdf first.


Ok, I try to be more explicit: Sometimes things go wrong and one has to delete all the aux, bbl, bcf etc. files. Some editor have this option but since we can compile a tex file with the terminal I was wondering whether there is also a function/program which would delete all those created auxiliary files automatically; e.g. $ cleartex . for all auxiliary files in that directory.

As moewe suggests such a program could have the gitignore list as base to work with.

  • 2
    I assume you would have to have a list of extensions of temporary files and then go through it and delete files you find with the extensions listed there. A start could be github.com/github/gitignore/blob/master/TeX.gitignore. I think I remember a different list with comments hosted on github, can't find it though.
    – moewe
    Commented Jun 28, 2018 at 7:34
  • 1
    erh, not understod, there are no aux files if the PDF has not been build. latexmk -c *.tex will remove all aux files generated from the given .tex files.
    – daleif
    Commented Jun 28, 2018 at 7:34
  • It isn't clear what you mean but rm *.aux removes all aux files from the current directory (or del rather than rm in windows cmd prompt) Commented Jun 28, 2018 at 8:10
  • What would be the reason to delete the auxiliary files before running TeX? They are essential for the next run of TeX to be correct (or, at least, more correct than the previous one).
    – egreg
    Commented Jun 28, 2018 at 8:23
  • 2
    yes, they are essential, but I might start compiling from scratch and having all auxiliary files deleted before compiling (and then keep them for the next rounds compiling). Commented Jun 28, 2018 at 11:44

1 Answer 1


Ok, easiest method I can up with so far is

latexmk -C my-file.tex

I quote from the manual of latexmk for the flag -C:

Clean up (remove) all regeneratable files generated by latex and bibtex or biber. This is the same as the -c option with the addition of dvi, postscript and pdf files, and those specified in the $clean_full_ext configuration variable. This cleanup is instead of a regular make ...

  • This command does not delete the bibtex aux files (.bib, .brf, .aux). Is there a way to do that too?
    – Kolja
    Commented Mar 25, 2022 at 10:59
  • I hope you do not really want to delete your bibliography file. That is something you do need. For the others you still can run rm *.{brf,aux} in your command line. Commented Mar 25, 2022 at 19:03
  • That was a mistake, I meant .bbl instead of .bib. I am aware of basic terminal commands, I just wanted to know if there was a latexmk or bibtex argument that would take care of that.
    – Kolja
    Commented Mar 25, 2022 at 19:30
  • 1
    Yeah, somehow not all of the aux/log/etc-files are deleted by latexmk -C. I ended up using a makefile and have a command like rm $(PROJECT)*.{blg,run.xml,toc,dep,fls,log,oai,bcf,bbl,aux,fdb_latexmk} to get all or at least most of those files. Commented Mar 25, 2022 at 19:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .