Skip to content

Instantly share code, notes, and snippets.

@djsutherland
Last active December 27, 2023 23:19
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save djsutherland/266983 to your computer and use it in GitHub Desktop.
Save djsutherland/266983 to your computer and use it in GitHub Desktop.
A bash script to clean latex temp files
#!/bin/bash
# Note: you might prefer latexmk -c since latexmk is great. It doesn't clean all of these, but see
# https://tex.stackexchange.com/questions/83341/clean-bbl-files-with-latexmk-c/83386#83386
exts=".aux .lof .log .lot .fls .out .toc .dvi .bbl .bcf .blg -blx.aux -blx.bib -blx.bib .run.xml .fdb_latexmk .synctex.gz .syntex.gz(busy) .pdfsync .algorithms .alg .loa .thm .nav .snm .vrb .acn .acr .glg .glo .gls .brf .lol .idx .ilg .ind .ist .maf .mtc .mtc0 .pyg .nlo .tdo .xdy .keys"
for x in "${@:-.}"; do
arg=$(echo ${x:-.} | perl -pe 's/\.(tex|pdf)$//')
if [[ -d "$arg" ]]; then
for ext in $exts; do
rm -f "$arg"/*$ext
done
else
for ext in $exts; do
rm -f "$arg"$ext
done
fi
done
# rm -rf $(biber --cache) # gross biber bug
@lawlist
Copy link

lawlist commented Mar 10, 2013

Thank you very much!

@AllanLRH
Copy link

AllanLRH commented Jun 3, 2013

Thanks a lot!

@hangong
Copy link

hangong commented Dec 1, 2014

Good!

@Agachon06
Copy link

Thx !

@zlatko-minev
Copy link

Yes! Saved me 5 mins

@callmexss
Copy link

THX!!!

@jxqiu77
Copy link

jxqiu77 commented Jun 20, 2019

Excellent!

@leomaurodesenv
Copy link

Nice one!

@ifilot
Copy link

ifilot commented Sep 18, 2019

Much appreciated!

@mhellmeier
Copy link

Great!

I also like to remove the generated stuff from biber / biblatex. Therefore I extended the exts variable to also remove bcf and run.xml files.
More information about the file extensions can be found here: https://tex.stackexchange.com/questions/7770/file-extensions-related-to-latex-etc

@skylogic004
Copy link

Thanks.
I added synctex to the list of extensions (because I don't gzip the synctex file because it doesn't work with my PDF viewer; this is done with -synctex=-1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment