OS/LINUX

find, grep 사용법

꼬져스 2016. 8. 12. 20:01
반응형

 

1. 폴더 또는 파일 찾기

   -> find 경로 -name 폴더명 또는 파일명

   -> 입력한 경로의 하위 경로까지 검색됨

 

2. 현재 디렉토리의 파일명 중에서 검색단어가 있는 코드 위치 찾기

   -> find . -name "파일명" -print -exec grep -n "검색단어" {} \;

 

3. 디렉토리의 파일명을 제외한 파일들을 삭제

   -> find 디렉토리 ! -name 파일명 -exec rm {} \;

 

4. 폴더 전체에서 파일 내부의 abc 라는 문자열 찾기

   -> grep -r abc /*

https://overcode.tistory.com/entry/%EB%A6%AC%EB%88%85%EC%8A%A4-%ED%8C%8C%EC%9D%BC-%EC%B0%BE%EA%B8%B0-%ED%8C%8C%EC%9D%BC%EC%86%8D-%EB%AC%B8%EC%9E%90%EC%97%B4-%EC%B0%BE%EA%B8%B0

 

리눅스 파일 찾기, 파일속 문자열 찾기

1. 리눅스 파일명으로 검색하는법. 사용법find [찾을위치] -name [파일명] 예) 최상위 폴더부터 하위로 'apache'로 시작하는 파일 찾기.find / -name 'apache*' 예) usr 폴더부터 하위로 'apa'로 시작하는 파일

overcode.tistory.com

https://zeuskwon-ds.tistory.com/135

 

[Linux] 파일 내 특정 문자열 찾기 - grep 기본

grep 명령어 - 파일 내 특정 문자열 찾기 리눅스에서 grep 명령어는 특정 파일에서 지정한 문자열이나 정규표현식을 포함한 행을 찾아서 출력해주는 명령어이다. 특히, tailo이나 ls 등 다양한 명령

zeuskwon-ds.tistory.com

 

 

참고)

http://solarixer.blogspot.kr/2007/09/find.html#!/2007/09/find.html

http://bahndal.egloos.com/524868

http://oiktoail.blog.me/220867152949