码迷,mamicode.com
首页 > 系统相关 > 详细

shell-清理日志

时间:2018-12-17 14:46:33      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:one   lse   echo   color   remove   txt   rem   for   clean   

#!/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
}

 

shell-清理日志

标签:one   lse   echo   color   remove   txt   rem   for   clean   

原文地址:https://www.cnblogs.com/shuiyonglewodezzzzz/p/10130744.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!