基于时间戳的grep文件 [英] grep files based on time stamp
问题描述
我想在时间实例后最后修改的头文件中搜索一个关键字(它是我的开始编译时间)和类似的xml文件,但单独的grep查询。
如果我在所有可能的头文件或xml文件上运行它,它会花费很多时间。只有那些是自动生成的。进一步的搜索必须是递归的,因为有很多的目录和子目录。
在当前目录及其子目录中递归地添加比 some_file
更新的所有文件中的$ c>'pattern':
find -newer some_file -type f -exec grep'pattern'{} +
您可以直接在 date -d
格式中指定时间戳,并使用其他 find
测试,例如 -name
, -mmin
。
如果 find
太慢,文件列表也可能由您的构建系统生成。
更具体工具,如 ack
, etags
,可以使用 GCCSense
来代替 grep
。
This should be pretty simple, but I am not figuring it out. I have a large code base more than 4GB under Linux. A few header files and xml files are generated during build (using gnu make). If it matters the header files are generated based on xml files.
I want to search for a keyword in header file that was last modified after a time instance ( Its my start compile time), and similarly xml files, but separate grep queries.
If I run it on all possible header or xml files, it take a lot of time. Only those that were auto generated. Further the search has to be recursive, since there are a lot of directories and sub-directories.
To find 'pattern'
in all files newer than some_file
in the current directory and its sub-directories recursively:
find -newer some_file -type f -exec grep 'pattern' {} +
You could specify the timestamp directly in date -d
format and use other find
tests e.g., -name
, -mmin
.
The file list could also be generate by your build system if find
is too slow.
More specific tools such as ack
, etags
, GCCSense
might be used instead of grep
.
这篇关于基于时间戳的grep文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!