2014. 9. 24. 11:09

# find [시작점] [옵션] [형식] -print

시작점 : 해당 디렉토리를 기준으로 해당 디렉토리 하위의 모든 파일 검색

-print 는 default로 적용 되어 있어 안써줘도 무방함.

 

find / -name app* -print

find / -size +102400k -print

find / -mtime -10 -print

 => mtime(modification time=수정시간), 최근 10일이내 변경된 파일만 검색

find / -atime -10 -print

 => atime(access time=접근시간), 최근 10일이내 접근한 파일 검색

 

------------------------------------------------------------------------------------------

find . -mtime +7 -type f  -exec rm{} \;

find . -mtime +7 -type f | wc -l

find . -mtime -20 -print

---------------------------------------------------------------------------------------------------------

 

# find 명령어 TIP

find / -name *.log -exec rm {}\;

 => log 라는 이름이 들어간 파일을 찾아서 삭제

find / -mtime +10 -exec rm {} \;

 => 10일 이전에 변경 된 파일을 찾아서 삭제 (ex. 다수 log 삭제 시 유용)

ex) find . -mtime +10 -type f -exec rm {} \;

 => 수정한 지 10일 이상된 파일 삭제

'Linux' 카테고리의 다른 글

리눅스 부팅모드  (0) 2014.09.26
ext 특징(extended file system)  (0) 2014.09.26
리눅스 패스워드 기한 변경  (0) 2014.09.18
SED  (0) 2014.09.16
vncserver  (0) 2014.09.11
Posted by 아도니우스