clearLog 新版本

function deleteLog(){
        local path pathList
        #path 为输入的路径
        path=$1
        #pathList为查找后的路径list
        pathList=$(find ${path} -name "*.log" -o -name "*.out" -o -name "*.log.*")
        for temp in ${pathList}
        do
                if test -f ${temp}
                then
                echo "清楚文件内容:" ${temp}
                #清除操作
                echo ${temp} > ${temp}

                elif test -d ${temp}
                then
                echo "是目录~ 不删除~" ${temp}

                else
                echo "what lixiaoguang10 ?!?"

                fi
        done
}

if test -d $1
then
         deleteLog $1
elif test -f $1
then
        echo "不是目录!"
        exit 1
else
        echo "目录或文件不存在!"
        exit 1
fi

  

猜你喜欢

转载自www.cnblogs.com/newface/p/10880538.html