본문 바로가기

개발/Server Side

find 명령어 응용

1. 확장자가 *.tar.gz 이고 용량이 10메가 이상인 파일 열거하기
# find / -type f -name *.tar.gz -size +10M -exec ls -l {} \;

2. 확장자가 *.tar.gz 이고 용량이 10메가 이상인 파일 삭제하기
# find / -type f -name *.tar.gz -size +10M -exec rm -f {} \;

3. 30일간 수정되지 않은 파일들을 "날짜_archive.tar"로 압축해서 저장하기
# find /home/yklee -type f -mtime +30 | xargs tar -cvf /tmp/`date '+%d%m%Y'_archive.tar`