How to grep a directory based on the timestamp of the file?


I am running the following command in a data directory:

$  grep -r '0xdataH2O' ./

There are a lot of files in this folder, and I’d only like to grep recent files. Is there a way to do something like the following:

$ grep -r '0xdataH2O' ./<$files_modified_within_last_two_days>


find . -type f -mtime -2 -exec grep -H 0xdataH20 {} \;

Answered By – William Pursell

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published