문서의 이전 판입니다!
# grep -R --include=GLOB "pattern" /path/to/dir grep -R --include="*.txt" "pattern" /path/to/dir grep -R --include="*.txt" "foo" ~/projects/
xargs
사용find . -name "*.java" | xargs grep "Some code to find"
findtext
#!/bin/sh # findtext "검색어" "파일명" find . -name "$2" | xargs grep -Hni "$1"
i
: 대소문자 구분안하기H
: 파일명 출력n
: 줄번호 출력-A [줄수]
: 매칭 되는 라인의 아래로 줄 수만큼 더 보여줌-B [줄수]
: 매칭 되는 라인의 위로 줄 수만큼 더 보여줌-C [줄수]
: -A
와 -B
둘 다 적용grep 'word1\|word2\|word3' /path/to/file ### Search all text files ### grep 'word*' *.txt ### Search all python files for 'wordA' or 'wordB' ### grep 'wordA*'\''wordB' *.py grep -E 'word1|word2' *.doc grep -e string1 -e string2 *.pl egrep "word1|word2" *.c
-l
: 매칭되는 문자열이 있는 파일 목록만 보여줌