grep命令遇到 Binary file matches解决方法
- 2019 年 12 月 10 日
- 筆記
报错
今天在grep数据库(Mysql)bilog文件的时候,终端返回报错:Binary file mysql-bin.000840 matches
。
[root@devops-ansible data]# grep "397736" mysql-bin.0008* Binary file mysql-bin.000840 matches Binary file mysql-bin.000842 matches Binary file mysql-bin.000843 matches Binary file mysql-bin.000844 matches Binary file mysql-bin.000845 matches Binary file mysql-bin.000847 matches
原因
因为mysql的binlog文件是二进制文件,grep不能直接读取二进制文件。
解决方法
grep -a " 要查找的内容" 文件 [root@devops-ansible data]# grep --help -a, --text equivalent to --binary-files=text # 让二进制文件等价于文本文件