#!/bin/bash # # Syntax: epurge [-h] [dir] # # Purpose: Removes all temporary files created by emacs from the directory # directory and its subdirectories. More specifically, removes # *~, #*# and .saves-*~ files. # The default value for dir is the current directory. # The -h flag shows the help info for this command. # Created: Nov 6, 1993 by Bart De Schutter # Last revised: Jan 22, 2002 by Bart De Schutter # # See http://www.deschutter.info/util/scripts.html for the latest version of # this script. # Status: public # Category: emacs 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 fi find "$ldir" \( -name '*~' -o -name '\#*\#' -o \ -name '.saves-*~' -o -name '.\#*' \) \ -exec \rm {} \;