사용자 도구

사이트 도구


linux:grep

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
linux:grep [2020/07/03 16:03]
kwon37xi [grep 대체]
linux:grep [2022/04/03 22:15]
kwon37xi
줄 2: 줄 2:
  
 ===== 특정 파일명에서 문자열 찾기 ===== ===== 특정 파일명에서 문자열 찾기 =====
-  * [[http://www.cyberciti.biz/faq/unix-linux-grep-include-file-pattern-recursive-example/|grep include file pattern recursive example]]<code sh> +<code sh> 
-grep -R --include=GLOB "pattern" /path/to/dir +현재 디렉토리 파일 한정 
-grep -R --include="*.txt" "pattern" /path/to/dir +grep <pattern> <file>
-grep -R --include="*.txt" "foo" ~/projects/+
 </code> </code>
-  * ''xargs'' 사용<code sh>+ 
 +  * [[http://www.cyberciti.biz/faq/unix-linux-grep-include-file-pattern-recursive-example/|grep include file pattern recursive example]] 
 +<code sh> 
 +# 하위 디렉토리를 포함하려면 -r --include=GLOB 을 사용 
 +# grep -r --include=GLOB "pattern" /path/to/dir 
 +grep -r --include="*.txt" "pattern" /path/to/dir 
 +grep -r --include="*.txt" "foo" ~/projects/ 
 + 
 +# -R 은 -r 과 같으나 모든 심볼릭 링크를 따라간다. 
 +</code> 
 +  * ''xargs'' 사용 
 +<code sh>
 find . -name "*.java" | xargs grep "Some code to find" find . -name "*.java" | xargs grep "Some code to find"
 </code> </code>
-  * ''findtext'' <code sh>+  * ''findtext''  
 +<code sh>
 #!/bin/sh #!/bin/sh
 # findtext "검색어" "파일명" # findtext "검색어" "파일명"
linux/grep.txt · 마지막으로 수정됨: 2023/05/15 17:03 저자 kwon37xi