shell-清理日志

#!/bin/bash
cleanFile()
{
  for i in $(ls $1); do
     if [[ $i == "kafka" ]]; then
        return
     elif [[ $i == "zk" ]]; then
        return
     fi
     if [[ -d ${i} ]]; then
        ch="${1}/${i}"
        cd ${ch}
        cleanFile ${ch}
        cd ..
     else
        #echo "${1}/${i}"
        if [[ ${i} =~ ".out" ]]; then
                echo "remove ${i}"
                rm -rf "${1}/${i}"
        elif [[ ${i} =~ ".log" ]]; then
                echo "remove ${i}"
                rm -rf "${1}/${i}"
        elif [[ ${i} =~ ".txt" ]]; then
                echo "remove ${i}"
                rm -rf "${1}/${i}"
        fi
     fi
  done
}

猜你喜欢

转载自www.cnblogs.com/shuiyonglewodezzzzz/p/10130744.html