MATHRICH@umcvmb.missouri.edu (Rich Winkel UMC Math Department) (03/24/89)
Are there any tools to do this, or do I have to move the contents of the directory somewhere else, remove the directory and re-create it? Thanks, Rich Winkel
rwl@uvacs.cs.Virginia.EDU (Ray Lubinsky) (04/04/89)
In article <18803@adm.BRL.MIL>, MATHRICH@umcvmb.missouri.edu (Rich Winkel UMC Math Department) writes: > Are there any tools to do this, or do I have to move the contents of the > directory somewhere else, remove the directory and re-create it? > > Thanks, > Rich Winkel Yes, you have to move them. But it's no big deal. Here's your tool: #! /bin/sh # # shrinkdir: shrink oversized directory files. PROG=shrinkdir for i in $* do if [ ! -d "$i" ] ; then echo "$PROG: $i is not a directory." continue fi mkdir $i.tmp$$ if [ $? -ne 0 ] ; then echo "$PROG: couldn't make temporary directory; $i not shrunk." continue fi mv $i/* $i/.[!.]* $i.tmp$$ if [ $? -ne 0 ] ; then echo "$PROG: couldn't empty $i; $i not shrunk." mv $i.tmp$$/* $i.tmp$$/.[!.]* $i 2>/dev/null rmdir $i.tmp$$ continue fi rmdir $i if [ $? -ne 0 ] ; then echo "$PROG: $i not replaced; contents left in $i.tmp$$" continue fi mv $i.tmp$$ `basename $i .tmp$$` done -- | Ray Lubinsky rwl@trinity.cs.virginia.edu (Internet) | | rwl@virginia (BITnet) | | Department of Computer Science, ...!uunet!virginia!uvacs!rwl (UUCP) | | University of Virginia (804) 979-6188 (voice) |