[K12OSN] OT Help with file deletion script
Jim Kronebusch
jim at winonacotter.org
Thu Oct 25 15:55:14 UTC 2007
> Remove the "do" from line 10 and the "done" from line 13. The
> if ...
> then
> .
> .
> .
> else
> .
> .
> fi
>
> is sufficient grouping.
Funny, I did that already :-) Here is what I have now:
#!/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 [ $deleteme != mail ] || [ $deleteme != .openwebmail ]
then
echo Removing $deleteme...
rm -ri $deleteme
else echo "Oops, encountered "$deleteme", not deleting!"
fi
done
done
I pulled the extra [ and ] from line 8 as well. Otherwise it gave me errors like so all
the way through and didn't remove anything:
./homedir_purge: 16: [[: not found
./homedir_purge: 16: [[: not found
Oops, encountered .update-manager-core, not deleting!
./homedir_purge: 16: [[: not found
./homedir_purge: 16: [[: not found
Oops, encountered .update-notifier, not deleting!
./homedir_purge: 16: [[: not found
./homedir_purge: 16: [[: not found
Oops, encountered Videos, not deleting!
./homedir_purge: 16: [[: not found
./homedir_purge: 16: [[: not found
Oops, encountered .Xauthority, not deleting!
But now it removes everything and doesn't pay attention to the 2 exceptions.
I am reading some script tutorials right now. Other suggestiosn?
--
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