基于时间戳的grep文件 [英] grep files based on time stamp

查看:111
本文介绍了基于时间戳的grep文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是非常简单的,但我没有搞清楚。我在Linux下有一个超过4GB的大代码库。构建期间会生成一些头文件和xml文件(使用gnu make)。



我想在时间实例后最后修改的头文件中搜索一个关键字(它是我的开始编译时间)和类似的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆