리눅스 n일 이상 된 파일 보기, 삭제하기

리눅스 n일 이상 된 파일들 보기, 삭제하기
리눅스 n일 이상 된 파일들 목록 보기, 지우기

1 특정 폴더의 파일들 보기[ | ]

find 폴더/ -maxdepth 1 -mtime +일수
# 또는
find 폴더/ -maxdepth 1 -mtime +일수 -print
[testuser@zetawiki backups]$ ll | grep backup
-rw-r--r-- 1 root root 1763639050 Apr 30 02:24 backup-2018_04_30.zip
-rw-r--r-- 1 root root 1763578550 May  1 02:20 backup-2018_05_01.zip
-rw-r--r-- 1 root root 1763563321 May  2 02:18 backup-2018_05_02.zip
-rw-r--r-- 1 root root 1763571990 May  3 02:16 backup-2018_05_03.zip
[testuser@zetawiki backups]$ find . -mtime +0
./backup-2018_05_02.zip
./backup-2018_04_30.zip
./backup-2018_05_01.zip
[testuser@zetawiki backups]$ find . -mtime +1
./backup-2018_04_30.zip
./backup-2018_05_01.zip
[testuser@zetawiki backups]$ find . -mtime +2
./backup-2018_04_30.zip

2 특정 폴더의 파일들 삭제하기[ | ]

find 폴더/ -maxdepth 1 -mtime +일수 -delete
# 또는
find 폴더/ -maxdepth 1 -mtime +일수 -exec rm {} \;

3 폴더 이하 모든 파일[ | ]

보기
find 폴더/ -mtime +일수 -print
삭제하기
find 폴더/ -mtime +일수 -delete
find 폴더/ -mtime +일수 -exec rm {} \;
특정 사이즈 이상 보기
  • 3000000Kbyte 이상(+)인 파일을 찾아서 ls명령을 -lh옵션으로 실행한다.
find . -size +3000000k -exec ls -lh {} \+

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}