#!/bin/bash # # Syntax: tpurge [-h] [dir] # # Purpose: Removes all auxiliary files created by latex from a directory. # More specifically, removes files with extensions .bak, .aux, .bbl, # .blg, .dvi, .lof, .log, .lot, .ind, .ilg, .inx, .toc, .idx, .ent, # .out, .los, .thm, and .pfg from the directory dir and its # subdirectories. Also removes the hidden .log files. # The default value for dir is the current directory. # The -h flag shows the help info for this command. # Created: Nov 8, 1993 by Bart De Schutter # Last revised: Jul 31, 2007 by Bart De Schutter # # See http://www.deschutter.info/util/scripts.html for the latest version of # this script. # Status: public # Category: latex if [ $# -ge 1 -a "$1" = "-h" ]; then sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi if [ $# -gt 1 ]; then echo >&2 echo >&2 "ERROR: ${0##*/} requires at most 1 input argument." echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi if [ $# -eq 0 ]; then ldir=. else ldir="$1" fi if [ ! -d "$ldir" ]; then echo >&2 echo >&2 "ERROR: Directory $ldir does not exist." echo >&2 exit 1 fi find "$ldir" \( -name '*.bak' -o -name '*.aux' -o -name '*.bbl' \ -o -name '*.blg' \ -o -name '*.dvi' -o -name '*.lof' -o -name '*.log' -o -name '*.lot' \ -o -name '*.ind' -o -name '*.ilg' -o -name '*.inx' \ -o -name '*.toc' -o -name '*.idx' -o -name '*.ent' \ -o -name '*.out' -o -name '*.los' -o -name '*.thm' \ -o -name '*.pfg' \ -o -name .log \) \ -exec \rm {} \;