[K12OSN] OT Help with file deletion script
Jim Kronebusch
jim at winonacotter.org
Thu Oct 25 17:24:17 UTC 2007
Thanks for the help guys. This is what I ended up with and it works perfectly (at least
in simulation :-)
#!/bin/sh
cd /home
for userdir in `ls -C1`
do
echo Working on $userdir...
cd /home/$userdir
for deleteme in `ls -C1 -a`
do
if [ "$userdir" = "support" ]
then
echo "Whoaa, not removing my main user!"
elif [ "$deleteme" = "mail" ]
then
echo "Oops, encountered "$deleteme", not deleting!"
elif [ "$deleteme" = ".openwebmail" ]
then
echo "Oops, encountered "$deleteme", not deleting!"
else
echo Removing $deleteme...
rm -rif $deleteme
fi
done
done
Scripting a rm -rif is scary! But it works. I couldn't get the if to work with both
folders on the same line, so I just broke them out with elif.
Thanks again,
Jim
--
This message has been scanned for viruses and
dangerous content by the Cotter Technology
Department, and is believed to be clean.
More information about the K12OSN
mailing list