programing

파일 확장자 별 git grep

nasanasas 2020. 10. 10. 10:08
반응형

파일 확장자 별 git grep


특정 확장자를 가진 파일에서만 패턴을 grep하려는 경우 다음과 같이 할 수 있습니다.

// searches recursively and matches case insensitively in only javascript files
// for "res" from the current directory
grep -iIr --include=*.js res ./

나는 git grep을 통해이 작업을 수행하는 방법을 찾고 있었지만 (트리와 함께 저장하는 색인에서 git grep의 속도를 활용하기 위해) 아무 소용이 없습니다. 여기서 특정 파일 형식을 제외 할 수 없다는 것을 알았 습니다 .


예, 예 :

git grep res -- '*.js'

이것을 시도하십시오 :

find . -type f -iname '*.js' -exec grep -i 'pattern' {} +

참고 URL : https://stackoverflow.com/questions/13867705/git-grep-by-file-extensions

반응형