Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$string['site:config']我想在我的文件夹中搜索这个特定的字符串。但是当我使用普通的 grep 函数grep -r "$string['site:config']"时,它会给我随机结果。
$string['site:config']
grep -r "$string['site:config']"
您的模式的问题在于,像这样$ [ ]的字符是用于定义正则表达式的字符,您必须对它们进行转义:
$ [ ]
grep "\$string\['site:config'\]"
或指示 grep 按原样查找给定的字符串:
grep -F "$string['site:config']"
而不试图将其解释为正则表达式。