如果您像这样使用grep grep -rnw '/your/path/to/search/' -e 'n getFoo' 使用grep无法找到包含“function getFoo()”的文件。 如果您只搜索'getFoo'或者'function getFoo',grep将会找到包含该函数的文件。 那么,最好的方法是如何查找包含字符串部分的文件呢? 提前感谢!
-w标志会导致整个单词匹配,因此可以清楚地看到你不需要的内容。 那么找到包含字符串部分的文件的最佳方法是什么? shopt -s globstar grep -li 'string to search for' /path/to/search/** shopt -u globstar