[Command]특정 파일 삭제 Command

2021. 1. 8. 12:20OS/Linux

[명령어]

# find [디렉토리] -name [파일명] -mtime +[일] -delete

# find [디렉토리] -name [파일명] -mtime +[일] -exec rm -f {} \;

# find [디렉토리] -name [파일명] -mtime +[일] | xargs rm -f

 

[(응용)현재 디렉토리 365일 이상 된 파일 삭제]

 - 대상 확인

# find ./ -mtime +366

 - 파일 삭제

# find ./ -mtime +366 -exec rm -f {} \;

 

[(응용)현재 디렉토리 사이즈 0 파일 삭제]

- 대상 확인

# find ./ -size 0

 - 파일 삭제

# find ./ -size 0 -exec rm -f {} \;

728x90

'OS > Linux' 카테고리의 다른 글

[장애대처]Root 패스워드 분실했을 경우  (0) 2021.01.12
[구성]repository 구성  (0) 2021.01.08
[Command] umount 정리  (0) 2021.01.06
[Command]mount 정리  (0) 2021.01.06
[Network]본딩(Bonding)  (0) 2020.06.12