Linux/CentOS & RHEL
[리눅스] find 파일 디렉터리 찾기
염불법사
2019. 10. 16. 10:41
자주 사용되는 옵션을 정리한해봄.
-type : 디렉터리 , 파일 구분해서 찾을때
d : 디렉터리
f : 파일
-size : 파일 사이즈
-ctime : 일단위
-mmin : 분단위
# 일정 날짜가 지난거 찾을때
# 파일 생성일이 최근 30분 안에 생긴거 찾기
shell >$ find ./ -type f -mmin -30
# 디렉터리가 생성된게 30일 지난거 찾기
shell >$ find ./-type d -ctime +30
# 특정 파일 사이즈 이상되는거 찾기
# 1k 이상되는 파일 삭제
shell >$ find ./ -type f -size +1k -delete
# -exec 활용
shell >$ find ./ -depth -type f -size +1k -exec rmdir {} \;
# 디렉터리 안에 파일이 하나도 없는것 삭제
shell >$ find ./ -type d -empty -delete
# -exec 활용
shell >$ find ./ -depth -type d -empty -exec rmdir {} \;