linux - 如何在 grep 中抑制二进制文件匹配结果

在linux中使用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 *

https://stackoverflow.com/questions/25853722/

相关文章:

linux - 如何就地对文件进行排序?

python - `ValueError: cannot reindex from a duplic

python - Python 的 any 和 all 函数是如何工作的?

python - 从 pandas.DataFrame 中选择复杂的标准

linux - 如何在linux中设置环境变量LD_LIBRARY_PATH

linux - 有没有办法按列 'uniq'?

linux - 我可以用/etc/hosts 映射一个主机名*和*一个端口吗?

python - 在 Python 中以编程方式生成视频或动画 GIF?

python - 使用 Python 的 os.path,我如何上一个目录?

linux - 如何在bash中创建仅包含十六进制字符而不包含空格的文件的十六进制转储?