在通配符目录循环中删除超过10天的文件

时间:2015-07-02 02:45:55

标签: bash shell unix

我想从多个目录中删除旧文件,但其中一个路径属性有一个外卡。所以我试图遍历每个目录而不指定每个目录。我想我几乎就在那里,但我不知道如何进入特定目录以删除相关文件。

#! /bin/bash

DELETE_SEARCH_DIR=/apps/super/userprojects/elasticsearch/v131/node*/elasticsearch-1.3.1/logs/

    for entry in `ls $DELETE_SEARCH_DIR`; do
      find $path -name "*super*"  -type f -mtime +10 -print -delete
      #find . -type f -name $entry -exec rm -f {} \;
    done

有关如何进入特定目录并应用删除的任何想法?

1 个答案:

答案 0 :(得分:1)

find可以搜索多个目录。你可以这样做:

DELETE_SEARCH_DIR=/apps/super/userprojects/elasticsearch/v131/node*/elasticsearch-1.3.1/logs
find $DELETE_SEARCH_DIR -type f -name '*super*' -mtime +10 -print -delete