- 리눅스 n일 이상 된 파일들 보기, 삭제하기
- 리눅스 n일 이상 된 파일들 목록 보기, 지우기
1 특정 폴더의 파일 보기
Bash
Copy
find 폴더/ -maxdepth 1 -mtime +일수
# 또는
find 폴더/ -maxdepth 1 -mtime +일수 -print
Console
Copy
[testuser@zetawiki backups]$ ll
total 28019204
-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 특정 폴더의 파일 삭제하기
Bash
Copy
find 폴더/ -maxdepth 1 -mtime +일수 -delete
Bash
Copy
find 폴더/ -maxdepth 1 -mtime +일수 -exec rm {} \;
3 폴더 이하 모든 파일
- 보기
Bash
Copy
find 폴더/ -mtime +일수 -print
- 삭제하기
Bash
Copy
find 폴더/ -mtime +일수 -delete
Bash
Copy
find 폴더/ -mtime +일수 -exec rm {} \;
- 특정 사이즈 이상 보기
- 3000000Kbyte 이상(+)인 파일을 찾아서 ls명령을 -lh옵션으로 실행한다.
Bash
Copy
find . -size +3000000k -exec ls -lh {} \+
4 같이 보기
편집자 Jmnote Estanthan7
로그인하시면 댓글을 쓸 수 있습니다.
- 분류 댓글:
- 리눅스 (19)
CentOS JDK 설치 ― …CentOS JDK 설치 ― ElliottCentOS vsftpd 설치 및 설정 ― …CentOS에서 apt-get 실행해보기 ― …CentOS에서 apt-get 실행해보기 ― 다미안VirtualBox 리눅스 인터넷 연결 ― …VirtualBox 리눅스 인터넷 연결 ― JmnoteVirtualBox 리눅스 인터넷 연결 ― …리눅스 CPU 사용률 확인 ― 동원잉리눅스 JDK 버전 확인 ― …리눅스 JDK 버전 확인 ― Jmnote리눅스 SSH 패스워드 없이 자동 로그인 ― …리눅스 SSH 패스워드 없이 자동 로그인 ― Jmnote리눅스 날짜 기준으로 파일 삭제하기 ― 백승현리눅스 날짜 기준으로 파일 삭제하기 ― Jmnote리눅스 디렉토리 용량 확인 du ― …리눅스 메모리 사용률 확인 ― 최재완리눅스 메모리 사용률 확인 ― Jmnote좀비 프로세스 찾기, 죽이기 ― 불량펭귄