David542
David542

Reputation: 110412

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>

Upvotes: 0

Views: 605

Answers (1)

William Pursell
William Pursell

Reputation: 212504

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

Upvotes: 1

Related Questions