Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!purdue!haven!uvaarpa!virginia!uvacs!rwl From: rwl@uvacs.cs.Virginia.EDU (Ray Lubinsky) Newsgroups: comp.unix.questions Subject: Re: shrinking directories under sunos 4 Message-ID: <3062@uvacs.cs.Virginia.EDU> Date: 3 Apr 89 21:31:28 GMT References: <18803@adm.BRL.MIL> Organization: U.Va. CS in Charlottesville VA Lines: 46 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) |