← 전체로 돌아가기
스킬 linux

리눅스 find 파일/폴더 찾기

find로 파일/폴더 찾고 삭제, -exec로 후처리 가능

linuxfindshellfile-managementdelete

find files

find . -name "._*" -type f

현재 폴더에서 "._*" 패턴 파일 찾기.

find . -name "._*" -type f -delete

찾은 파일 바로 삭제함.

-exec 옵션으로 후처리 가능. {}는 find 결과로 퉁침.

find [경로] -type d -name "20240630" -exec rm -rf {} \;

[경로]에서 20240630 이름 폴더 찾아 바로 지움.

여기서 배울 것

  1. find로 특정 패턴 파일 찾기
  2. 찾은 파일 바로 삭제 가능
  3. -exec로 find 결과에 명령 적용
  4. 폴더도 이름으로 찾아 지울 수 있음
원본 파일 보기 (.claude/skills/tn-linux-find-files/SKILL.md)
---
name: Linux `find` 명령어 활용
description: Use when the user needs to locate or delete files and directories on a Linux system based on specific criteria such as name patterns, file types, or modification times, using the `find` command.
version: 1.0.0
source: /home/son/prj/resume/backup_notes_260317/notion/Tech Note/linux find files 304d7efd824b80fabf01d45498792692.md
---

# linux find files

find . -name "._*" -type f

find . -name "._*" -type f -delete

-exec 붙이면 후처리 가능

{} = 나온 결과

```
find /경로/ -type d -name "20240630" -exec rm -rf {} \;
```

출처:

[https://betwe.tistory.com/entry/간단-명령어-find-명령어로-특정-패턴-폴더-또는-파일-삭제](https://betwe.tistory.com/entry/%EA%B0%84%EB%8B%A8-%EB%AA%85%EB%A0%B9%EC%96%B4-find-%EB%AA%85%EB%A0%B9%EC%96%B4%EB%A1%9C-%ED%8A%B9%EC%A0%95-%ED%8C%A8%ED%84%B4-%ED%8F%B4%EB%8D%94-%EB%98%90%EB%8A%94-%ED%8C%8C%EC%9D%BC-%EC%82%AD%EC%A0%9C)

[개발과 육아사이:티스토리]