grep或zgrep的时候Binary file (standard input) matches 怎么解决?

转自:http://blog.csdn.net/iori97king/article/details/5917824


操作 grep "xxx" a.log

结果 Binary file a.log matches

原因:grep认为a.log是二进制文件

 

解决方法:grep-a"xxx" a.log

 

可以看看grep -a参数的功能

[appadmin@test3 ~/tmp]$ grep --help |grep '/-a'
-a, --text               equivalent to --binary-files=text

即,让二进制文件等价于文本文件


注:zgrep遇到同类问题时,解决方法是一样的