哪个更有效地查找整个文件系统中的哪些文件包含字符串:递归 grep 或在 exec 语句中使用 grep 查找?我认为 find 会更有效,因为如果您知道文件扩展名或与文件名匹配的正则表达式,您至少可以进行一些过滤,但是当您只知道-type f哪个更好时?GNU grep 2.6.3;查找(GNU findutils)4.4.2
例子:
grep -r -i 'the brown dog' /
find / -type f -exec grep -i 'the brown dog' {} \;