Tuesday, July 26, 2005
Bash Shell Script
Say you have a number of project directories, each with a /bin for compiled Java classes, how would you remove everything under /bin except the CVS directory ? Here is a bash shell script that will do the job:
for i in `ls`
do
if [ -d $i/bin ]
then
cd $i/bin
for i in `ls`
do
if test "$i" = "CVS"
then
pwd
else
rm -Rf $i
fi
done
cd ../..
fi
done