bash 我如何 grep 反引号?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6792108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I grep for a backtick?
提问by bafromca
So I'm trying to find backticks (`) in files, so I ran:
所以我试图在文件中找到反引号(`),所以我跑了:
grep -irl '\`' ./*
This seems to return every single file possible...
这似乎返回了每个可能的文件......
What else can I try?
我还能尝试什么?
采纳答案by bafromca
My apologies everyone, you have to use -Ito ignore binary files. Those were the files that were being returned. I didn't realize this until I removed -l, which indicated to me that the results were binary in nature.
我向大家道歉,您必须使用-I忽略二进制文件。这些是被退回的文件。直到我删除-l,我才意识到这一点,这向我表明结果本质上是二进制的。
grep -rlI '`' ./*
From the man page:
从手册页:
-I Process a binary file as if it did not contain matching data;
this is equivalent to the --binary-files=without-match option.
回答by Tyler Hains
If you don't actually need to match the backtick itself, but you are looking to match something enclosed by a backtick ( like auto-generated MySQL table names, for instance) a single-character wildcard (".")also does the trick.
如果您实际上不需要匹配反引号本身,但您希望匹配由反引号括起来的内容(例如自动生成的 MySQL 表名),则单字符通配符(".")也可以解决问题.
I'm using it like this today:
我今天是这样使用它的:
grep "INSERT INTO .my_table." sqldump.sql
回答by marcelog
just go with, it worked for me
就去吧,它对我有用
grep -ri \` *
回答by TMS
grep -irl '`' *
or
或者
grep -irl \` *

