在许多文件中查找单词

ant*_*009 2 linux grep command-line find

我正在寻找这个struct messages_sdd_t,我需要搜索很多 *.c 文件才能找到它。但是,我找不到匹配项,因为我想排除所有单词“struct”和“messages_sdd_t”。因为我只想搜索这个 'struct messages_sdd_t' 原因是,因为 struct 被使用了很多次,我一直在获取页面或搜索结果。

我一直这样做没有成功:

find . -type f -name '*.c' | xargs grep 'struct messages_sdd_t'
Run Code Online (Sandbox Code Playgroud)

和这个

find . -type f -name '*.c' | xargs egrep -w 'struct|messages_sdd_t'
Run Code Online (Sandbox Code Playgroud)

非常感谢您的任何建议,

Iva*_*hev 5

使用确认

确认“struct messages_sdd_t”*.c

默认情况下它是递归的,并且grep在搜索包含大量源代码的目录时比(根据我的观察)快得多。

如果你不想使用ack,也grep应该没问题:

grep -r "struct messages_sdd_t" *.c