문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
linux:find [2012/12/02 19:24] kwon37xi |
linux:find [2020/09/17 12:06] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 1: | 줄 1: | ||
| ====== find ====== | ====== find ====== | ||
| + | * [[http:// | ||
| + | * [[linux: | ||
| * [[http:// | * [[http:// | ||
| + | * [[linux: | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | ===== 정규표현식 regex ===== | ||
| + | * 정규표현식으로 파일을 찾을 때는, 파일 이름뿐 아니라 파일 앞의 디렉토리 명까지 고려해서 정규표현식을 작성해야 한다.< | ||
| + | # 파일 이름이 숫자.txt 인 것들 | ||
| + | find . -regex " | ||
| + | </ | ||
| + | |||
| + | ===== 특정 시점 이후/ | ||
| + | * '' | ||
| + | # 30일 보다 이전에 수정된 파일들 | ||
| + | find . -mtime +30 | ||
| + | |||
| + | # 딱 30일 전에 수정된 파일 | ||
| + | find . -mtime 30 | ||
| + | |||
| + | # 시간 비교시 해당 일의 시작 시간(00: | ||
| + | find . -mtime 30 -daystart | ||
| + | |||
| + | # 30일 전 이후(오늘 부터 30일 전까지 사이)에 수정된 파일 | ||
| + | fine . -mtime -30 | ||
| + | </ | ||
| + | |||
| + | ===== depth ===== | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | ===== type ===== | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | ===== 파일 이름만 가져오기 ===== | ||
| + | [[http:// | ||
| + | |||
| + | <code sh> | ||
| + | find ./dir1 -type f -exec basename {} \; | ||
| + | find /dir1 -type f -printf " | ||
| + | </ | ||
| + | |||
| + | ===== -ignore_readdir_race/ | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | ===== 동일 이름 파일 목록 얻기 ===== | ||
| + | <code sh> | ||
| + | find . -type f -printf " | ||
| + | </ | ||
| + | |||
| + | ===== 하위 디렉토리에 존재하는 파일 갯수 ===== | ||
| + | <code sh> | ||
| + | find */ | cut -d/ -f1 | uniq -c | ||
| + | </ | ||
| + | |||
| + | ===== 특정 날짜의 모든 로그 파일들 중에서 grep ===== | ||
| + | 로그 파일이 한 날짜에 굉장히 많을 때(예: Jenkins build log) 특정 날짜의 로그 파일만 찾아서 거기서 특정 문자열 검색 | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | <code sh> | ||
| + | # 날짜 기준이 생성일이라고 | ||
| + | find . -name *.log -newerct yyyy-MM-dd ! -newerct yyyy-MM-dd -exec grep -Hni ' | ||
| + | </ | ||
| + | |||