Linux

find 고찰 및 활용

Leo 리오 2011. 9. 19. 20:12
반응형
#find -name $filename
$filename의 이름을 가진 파일을 찾는다. (RE로 정확히 매칭)
recursive하다.
 


#find -perm -u+x
user permission이 x(execute)인 파일들을 찾는다.
 


#find -type f
폴더를 제외한 파일만(?) 찾는다.
 


#find ........ | xargs file
.......조건으로 찾은 파일들의 정보를 본다.
( #file  $files )
찾은 파일이 가장 마지막의 argument로 들어가게 된다.
 

 
#find ........ -exec cp {} directory/ \;
.......조건으로 찾은 파일들을 directory/로 복사.
( #cp $files directory/ )
찾은 파일이 {}자리의 argument로 들어가게 되고 \;는 끝을 알린다.



#find . -name "*.c" -type f -exec grep xx {} \; 
#find . -name "*.c" -type f | xargs grep xx 

모든 *.c파일들중에서 xx가 들어간 파일을 찾음.

 
반응형