我向大家道歉,你必须使用-I忽略二进制文件.那些是被退回的文件.在我删除之前我没有意识到这一点-l,这表明结果本质上是二元的.
grep -rlI '`' ./*
Run Code Online (Sandbox Code Playgroud)
从手册页:
   -I     Process a binary file as if it did not contain  matching  data;
          this is equivalent to the --binary-files=without-match option.
Run Code Online (Sandbox Code Playgroud)
        小智 5
如果您实际上不需要匹配反引号本身,但您希望匹配反引号括起来的内容(例如自动生成的 MySQL 表名),那么单字符通配符(“.”)也可以解决问题。
我今天这样使用它:
grep "INSERT INTO .my_table." sqldump.sql
Run Code Online (Sandbox Code Playgroud)