반응형
grep에서 이진 파일 일치 결과를 억제하는 방법
grep
리눅스에서 사용할 때 , 결과는 종종 많은 "이진 파일 XXX 일치"를 포함하는데, 나는 상관하지 않습니다. 결과 의이 부분을 억제하는 방법 또는 grep에서 이진 파일을 제외하는 방법은 무엇입니까?
사용할 수있는 세 가지 옵션이 있습니다. -I
grep에서 이진 파일을 제외하는 것입니다. 다른 라인 번호와 파일 이름입니다.
grep -I -n -H
-I -- process a binary file as if it did not contain matching data;
-n -- prefix each line of output with the 1-based line number within its input file
-H -- print the file name for each match
그래서 이것은 grep을 실행하는 방법 일 수 있습니다 :
grep -InH your-word *
이것은 오래된 질문이며 대답은되었지만 사용하려는 사람을 위해 --binary-files = text 옵션을 여기에 넣을 것이라고 생각했습니다. -I 옵션은 이진 파일을 무시하지만 grep이 이진 파일을 텍스트 파일로 취급하도록하려면 --binary-files = text를 다음과 같이 사용하십시오.
bash$ grep -i reset mediaLog*
Binary file mediaLog_dc1.txt matches
bash$ grep --binary-files=text -i reset mediaLog*
mediaLog_dc1.txt:2016-06-29 15:46:02,470 - Media [uploadChunk ,315] - ERROR - ('Connection aborted.', error(104, 'Connection reset by peer'))
mediaLog_dc1.txt:ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))
bash$
참고 URL : https://stackoverflow.com/questions/25853722/how-to-suppress-binary-file-matching-results-in-grep
반응형
'Programing' 카테고리의 다른 글
Makefile의 현재 상대 디렉토리를 얻는 방법? (0) | 2020.05.20 |
---|---|
"현재 모델에는 '모델'이라는 이름이 없습니다." (0) | 2020.05.20 |
GitHub 리포지토리의 포크 종속성 삭제 (0) | 2020.05.19 |
C # 자동 속성 초기화 (0) | 2020.05.19 |
다른 ORDER BY로 PostgreSQL DISTINCT ON (0) | 2020.05.19 |