문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
linux:grep [2014/05/26 11:55] kwon37xi |
linux:grep [2023/05/15 17:03] (현재) kwon37xi [Pattern 옵션] |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== grep ====== | ====== grep ====== | ||
+ | * [[: | ||
===== 특정 파일명에서 문자열 찾기 ===== | ===== 특정 파일명에서 문자열 찾기 ===== | ||
- | * [[http:// | + | <code sh> |
- | grep -R --include=GLOB " | + | # 현재 디렉토리 파일 한정 |
- | grep -R --include=" | + | grep <pattern> < |
- | grep -R --include=" | + | |
</ | </ | ||
- | | + | |
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | <code sh> | ||
+ | # 하위 디렉토리를 포함하려면 -r --include=GLOB 을 사용 | ||
+ | # grep -r --include=GLOB " | ||
+ | grep -r --include=" | ||
+ | grep -r --include=" | ||
+ | |||
+ | # 모든 파일 검색하고 줄번호도 함께 출력 | ||
+ | grep -rn " | ||
+ | |||
+ | # * 가 없으면 / | ||
+ | # / | ||
+ | grep -rn " | ||
+ | |||
+ | # -R 은 -r 과 같으나 모든 심볼릭 링크를 따라간다. | ||
+ | </ | ||
+ | | ||
+ | <code sh> | ||
find . -name " | find . -name " | ||
</ | </ | ||
- | * '' | + | * '' |
+ | <code sh> | ||
#!/bin/sh | #!/bin/sh | ||
# findtext " | # findtext " | ||
find . -name " | find . -name " | ||
</ | </ | ||
- | * '' | + | * '' |
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ===== 매칭되는 줄 위아래 보여주기 ===== | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ===== 정규표현식 / Regex/ Pattern | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * [[https:// | ||
+ | * '' | ||
+ | * '' | ||
+ | ===== 여러 단어 검색 ===== | ||
+ | * [[https:// | ||
+ | <code sh> | ||
+ | grep ' | ||
+ | ### Search all text files ### | ||
+ | grep ' | ||
+ | ### Search all python files for ' | ||
+ | grep ' | ||
+ | grep -E ' | ||
+ | grep -e string1 -e string2 *.pl | ||
+ | egrep " | ||
+ | </ | ||
+ | |||
+ | ===== 기타 옵션 ===== | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ===== grep 대체 ===== | ||
+ | * [[linux: | ||
+ | * [[linux: | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// |