#! /bin/sh
if [ $# -lt 1 ];then
echo usage:$0 filename
exit
fi
echo "All the files will be deleted except for:"
echo " $*"
echo "Are you sure[y/n]?\c"
read answer
if [ x$answer != "xy" ];then
exit
fi
for file in * ;do
# echo processing $file
remove=yes
for arg in $@ ;do
if [ $file = $arg ];then
remove=no
break
fi
done
if [ $remove = "yes" ];then
if [ -d $file ];then
echo "$file is a directory, remove it?[y/n]\c"
read answer
if [ x$answer = "xy" ];then
rm -rf $file
fi
else
rm $file
fi
fi
done
No comments:
Post a Comment