#!/bin/sh # Time-stamp: <1999-03-21 02:30:37 ttate> # # clean -- delete files named core,*~,#* # Author: Takaaki Tateishi # Lisence: Free for any use # # Require: # GNU find, rm, mv # # USAGE: # clean [-R|-r|--recursive] [-t|--use-tmp] [-T tmp-dir] [-i] directory # FIND=find TMP=/tmp RM="rm -f" RM2="rm -i" MV="mv -f" USETMP="no" RECURSIVE="no" TARGET=. while test "$1" != "" do case "$1" in "-R"|"-r"|"--recursive") RECURSIVE="yes"; shift;; "-t"|"--use-tmp") USETMP="yes"; shift;; "-T") USETMP="yes"; shift; TMP=$1; shift;; "-i") RM=$RM2; shift;; "-"*) echo "unknown option."; exit;; *) TARGET=$1; shift;; esac done if test "$RECURSIVE" = "yes" then if test "$USETMP" = "yes" then $FIND $TARGET \ \( \( ! -path "$TMP" \) -and \ \( -name ".*~" -o -name "*~" -o -name "#*" -o -name core \) \) \ -exec $MV {} $TMP \; else $FIND $TARGET \ \( -name ".*~" -o -name "*~" -o -name "#*" -o -name core \) \ -exec $RM {} \; fi else if test "$USETMP" = "yes" then for f in $TARGET/*~ $TARGET/#* $TARGET/core $TARGET/.*~ do if test -f "$f" then $MV $f $TMP fi done else for f in $TARGET/*~ $TARGET/#* $TARGET/core $TARGET/.*~ do if test -f "$f" then $RM $f fi done fi fi