find 를 이용한 파일 검색 


1. Syntax

   # find path-name expression


2. Operands

* path-name : 상대 path-name 또는 절대 path-name 모두 사용가능

* 주로 사용하는 expression

       -name pattern             : file name 으로 검색  

       -mtime n                     : modify time 으로 검색 

       -perm [-]mode          : file permission 으로 검색 

       -size n[c]                  : file size 로 검색 

       -user user-name       : file owner 로 검색 

       -exec command         : 명령어 수행 

       -print                           : find 결과를 화면에 display (default  로 지정되어 있음) 

       -ls                               : find 결과에 대한 ls -l 명령을 수행해 dispaly


3. Example

 

   # find . -name "sc*" -print  또는 # find . -name "sc*"

     /* 현재 directory 를 기준으로 sc로 시작하는 file 을 찾아 display */

 

   # find / -mtime 30 -print -exec rm {} \;

     /* 모든 directory  에서 30일 전에 수정된 file display 하고 그 file 들을 삭제함 */

 

   # find . -perm -4000 -user root -ls

     /* root user setuid 가 정의되어 있는 file 을 찾아 display */

 

   # find . -size +1000000c -ls

     /* file size 1MB 가 넘는 것을 찾아 display */

 

   # find . -size +1000000c -print -exec rm {} \;

     /* file size 1MB 가 넘는 것을 찾아 display  하고 그 file 들을 삭제함 */

http://blog.nice2seeyou.com/mike/trackback/197
YOUR COMMENT IS THE CRITICAL SUCCESS FACTOR FOR THE QUALITY OF BLOG POST