Linux:: find명령어

Published by onesixx on

sudo find [경로]    [옵션1] [조건1]    [옵션2] [조건2] … 2>/dev/null

파일명 찾기

find / -name ‘찾을단어’ 

$ find . -name 'a*.php'
$ find /home/sixx -name 'ab' 2>/dev/null
$ find / -name '[a-zA-Z]' -type f -ls

폴더명 찾기 

$ find / -name 'abc' -type d

옵션 순서를 바꾸면 에러 남.

 -type  
f:파일 d:디렉터리 l:심볼릭 파일 

파일 내에 특정 문자열을 검색

$ find . -name "*.txt" | xargs grep abc

정규식 파일 찾은 후 삭제

$ find . -name "cell_data_2*" -type f -exec rm {} \\;

찾은 파일 삭제

포멧 호환성 때문에 생긴 ._ 파일 삭제

$ find ./ -name ._\\* -delete
Categories: Ubuntu

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x