Grep inside all files created within date range

前端 未结 3 722
我在风中等你
我在风中等你 2020-12-03 00:54

I am on the Ubuntu OS. I want to grep a word (say XYZ) inside all log files which are created within date range 28-may-2012 to 30-may-2012.

How do I do that?

3条回答
  •  心在旅途
    2020-12-03 01:33

    find doesn't seem to have options where you can specify specific dates for timestamp comparison (at least the version on my laptop doesn't - there may be other versions and/or other tools that perform similarly), so you'll have to use the number of days. So, as of 2012/06/05, you want to find files newer than 9 days but older than 6 days:

    find . -type f -ctime -9 -ctime +6 -print0 | xargs -0 grep XYZ
    

提交回复
热议问题