find를 사용하여 파일 목록을 필터링하는 방법이 있습니까?

find를 사용하여 파일 목록을 필터링하는 방법이 있습니까?

내 결과는 locate --existing --regex매우 빠르게 얻어졌습니다. 비슷한 프로세스를 find수행하려면 몇 시간이 걸립니다. 이는 엄청난 양입니다.

find이 파일 목록에 추가 필터를 적용하고 싶습니다 .

내가 찾은 유일한 지름길은 동일한 검색을 두 번 적용하는 것입니다. 먼저 :를 사용하여 이러한 파일이 포함된 디렉터리 목록을 가져온 locate다음 비재귀적으로 실행합니다 find.

# Abandoned Office temporary files
PATTERN='/foo/.+/~$[^/]+'

# locate doesn't re-enter the same path so sort before uniq is unnecessary.
# --existing is unnecessary, since locality of reference and thus
# performance and load are better when stat-ing the entries is done only
# once by `find`
locate --regex "$PATTERN" | xargs -d\\n -L1 dirname -- | uniq | \
  while read -r path; do
    find "$path" -maxdepth 0 -regex "$PATTERN" -type f -ctime +30 -exec rm '{}' ';'
  done

이 작업을 수행하는 덜 복잡한 방법이 있습니까?

관련 정보