grep提示"Binary file (standard input) matches"

发布时间 2024-01-11 09:41:11作者: wh459086748

一、问题现象

[root@test ~]# cat 2e44fc3e1551879f86112ff36ef7671b313a7d0d7ad52ff8b5b080e850e10f50-json.log-20240110 |grep  '2024-01-10'
Binary file (standard input) matches

二、解决思路

[root@test ~]# cat 2e44fc3e1551879f86112ff36ef7671b313a7d0d7ad52ff8b5b080e850e10f50-json.log-20240110 |grep  -a '2024-01-10'

想要按文本格式来查看需要在grep后面加-a参数即可,也就是需要使用grep -a 

grep原本是搜寻文字文件,若拿二进制的文件作为搜寻的目标,

则会显示如下的讯息: Binary file 二进制文件名 matches 然后结束。

若加上-a参数则可将二进制档案视为文本文件搜寻,

相当于--binary-files=text这个参数。

参考地址:https://jingyan.baidu.com/article/358570f6f41b35ce4624fc69.html