【发布时间】:2015-11-15 23:14:56
【问题描述】:
我在终端中使用此命令find . -type f -exec grep -Hn 'TEXT' {} \; 查找文件中TEXT 的所有文件,但现在我想查找当前目录中TEXT 不在文件中的所有文件。
【问题讨论】:
-
是的,它是重复的。之前找不到这个链接。谢谢
标签: bash unix terminal grep find
我在终端中使用此命令find . -type f -exec grep -Hn 'TEXT' {} \; 查找文件中TEXT 的所有文件,但现在我想查找当前目录中TEXT 不在文件中的所有文件。
【问题讨论】:
标签: bash unix terminal grep find
所有POSIX-compliant grep 实现都应该有-v 选项:
-v
Select lines not matching any of the specified patterns. If the -v
option is not specified, selected lines shall be those that match any
of the specified patterns.
所以列出不包含TEXT的文件的命令应该是:
$ find . -type f -exec grep -lv 'TEXT' {} \;
【讨论】:
-v,但-lv 在这里会更好。我会修正我的答案。