find [path] [options] [expression]
-name "pattern" | "패턴" 으로 파일 조회 |
-iname "pattern" | "패턴" 으로 파일 조회 |
-type [f/d/l] | 유형 [f/d/l] 유형별로 조회 :f (파일),d (디렉토리),l (Symlink). |
-size [+/-N]c | 크기별로 조회 :n bytes,+n (큰),-n (작은). |
-empty | 빈 파일 또는 디렉토리 조회 |
-user username | 특정 사용자가 소유 한 파일 조회 |
-group groupname | 특정 그룹에 속하는 파일 조회 |
-perm 644 | 644 권한 파일 조회 |
-perm -u+x | 사용자 실행 권한이 있는 파일 조회 |
-mtime [+/-N] | 며칠전에 수정 된 파일 조회 (+N = older, -N = newer). |
-atime [+/-N] | 며칠 전에 액세스 한 파일 조회 |
-ctime [+/-N] | 메타 데이터가 며칠 전에 변경된 파일 조회 |
-newer file | '파일'보다 최근에 수정 된 파일 조회 |
-delete | 일치하는 파일 삭제 |
-exec command {} \; | 찾은 파일에서 명령을 실행 |
-exec command {} + | 한 번에 여러 파일에서 명령을 실행 |
일치하는 파일 인쇄 | |
-ls | 찾은 파일의 세부 사항을 나열 |
ex)
#1 . /home/user **에서.txt 파일을 모두 조회
find /home/user -type f -name "*.txt"
#2 . 빈 파일을 찾아 삭제
find /path/to/search -type f -empty -delete
#3 . 100MB보다 큰 파일 찾기
find /path/to/search -type f -size +100M
#4 . 지난 7 일 동안 수정 된 파일 찾기
find /path/to/search -type f -mtime -7
#5 . 모든.sh 파일 의 권한 찾기 및 권한 변경
find /path/to/search -type f -name "*.sh" -exec chmod +x {} \;
#6 . 30 일보다 오래된 '.log` 파일을 찾고 삭제
find /path/to/logs -type f -name "*.log" -mtime +30 -exec rm {} \;
#7 . 특정 사용자가 소유 한 파일 찾기
find /path/to/search -type f -user username
'Linux' 카테고리의 다른 글
Linux - Shebang (0) | 2025.03.16 |
---|---|
Linux - crontab (0) | 2025.03.09 |
Linux - grep (0) | 2025.03.02 |
Linux - TOP (0) | 2025.01.12 |
Linux - TOP command (1) | 2024.05.21 |