删除目录的脚本
时间:2010-10-21 来源:ccjsj1
#!/bin/sh
SYSLOG=/home/neo/findtest/syslog
APPLOG=/home/neo/findtest/applog
for LOG in $SYSLOG $APPLOG ; do
var=`find $LOG -maxdepth 1 -type d | awk '{if(NR>1) print}' | wc -l` > /dev/null if [ $var -ne 0 ] ; then
arr=(`find $LOG -maxdepth 1 -type d | awk '{if(NR>1)print}'`) rm -rf $(find $LOG -maxdepth 1 -type d | awk '{if(NR>1)print}')
for((i=0;i<var;i++)); do
echo "rm ${arr[i]} directory ok."
done
echo "at" `date +%Y-%m-%d-%H-%M-%S` "all rm ok."
echo -e "\n\n"
else
echo "at $LOG under no directory."
echo -e "\n\n"
fi
done exit 0
var=`find $LOG -maxdepth 1 -type d | awk '{if(NR>1) print}' | wc -l` > /dev/null if [ $var -ne 0 ] ; then
arr=(`find $LOG -maxdepth 1 -type d | awk '{if(NR>1)print}'`) rm -rf $(find $LOG -maxdepth 1 -type d | awk '{if(NR>1)print}')
for((i=0;i<var;i++)); do
echo "rm ${arr[i]} directory ok."
done
echo "at" `date +%Y-%m-%d-%H-%M-%S` "all rm ok."
echo -e "\n\n"
else
echo "at $LOG under no directory."
echo -e "\n\n"
fi
done exit 0
相关阅读 更多 +