bash Grep '二进制文件匹配'。如何获得正常的grep输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23512852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Grep 'binary file matches'. How to get normal grep output?
提问by davidbain
I've got a grep script that searches through a directory recursively.
我有一个 grep 脚本,它递归地搜索目录。
grep -n -R -e 'search term' -e 'second search term' ./
However the results I get are the following. Notice there are found matches in JPGs but no actual result.
但是我得到的结果如下。请注意,在 JPG 中找到了匹配项,但没有实际结果。
Binary file ./jpg/00015928.jpg matches
Binary file ./jpg/00015296.jpg matches
Binary file ./jpg/00020072.jpg matches
Is there any way to see the result in the output like a normal grep search?
有没有办法像普通的grep搜索一样在输出中查看结果?
回答by perreal
Try:
尝试:
grep --text
or
或者
grep -a
for short. This is equivalent to --binary-files=text
and it should show the matches in binary files.
简称。这等效于--binary-files=text
并且应该在二进制文件中显示匹配项。