cleanup script needed
Chris Torek
chris at mimsy.UUCP
Fri May 12 11:43:51 AEST 1989
In article <5520003 at hplsla.HP.COM> dans at hplsla.HP.COM (Dan Siler) writes:
[large chunks of shell script deleted]
> for i in $junkfiles
> do
> echo "removing any $i junk files..."
> find / -name $i -exec rm {} \;
> done
If you have anything other than a tiny file system, it is much faster
to run a single `find' that removes `junk' rather than several separate
`find's. E.g.:
pat=`echo -n -name; echo $junkfiles | sed -e 's/ / -o -name /'"
find / \( $pat \) -exec /bin/rm {} \;
(the assignment to `pat' above can be deleted in the obvious manner);
or just write it directly. This is the script we run each night:
find / \( \( -name '#*' -atime +1 \) \
-o \( -name ',*' -atime +1 \) \
-o \( \( -name '*.bak' \
-o -name '*.dvi' \
-o -name '*.CKP' \
-o \( \
-name '*~' \
! -name 'Mail.help.~' \) \
-o -name '.*.bak' \
-o -name '.*.CKP' \
-o -name '.*~' \) -atime +3 \) \
-o \( -name '.emacs_[0-9]*' -atime +7 \) \
-o \( -name core \) \
\) -print -exec /bin/rm -f {} \; > /tmp/.cleanup 2>&1
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.questions
mailing list