Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!dogie.macc.wisc.edu!uwvax!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: cleanup script needed Message-ID: <17459@mimsy.UUCP> Date: 12 May 89 01:43:51 GMT References: <19510@adm.BRL.MIL> <5520003@hplsla.HP.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 35 In article <5520003@hplsla.HP.COM> dans@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@mimsy.umd.edu Path: uunet!mimsy!chris