shrinking directories under sunos 4
Ray Lubinsky
rwl at uvacs.cs.Virginia.EDU
Tue Apr 4 07:31:28 AEST 1989
In article <18803 at adm.BRL.MIL>, MATHRICH at 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 at trinity.cs.virginia.edu (Internet) |
| rwl at virginia (BITnet) |
| Department of Computer Science, ...!uunet!virginia!uvacs!rwl (UUCP) |
| University of Virginia (804) 979-6188 (voice) |
More information about the Comp.unix.questions
mailing list