Using bash to find a file modified in a specific date/time interval?


Did you ever need to find a file stored somewhere in a bunch of folders, which you didn’t remember the name, but you remember about when you last modified the file? At work, it sometimes happens that I need to find some log file, among 20 Gigs of log files, which was modified on a certain day. Here is a simple bash trick to do just that:

 touch -d "13 october 2006 15:00:00" ~/date_start
 touch -d "14 october 2006 21:00:00" ~/date_end
 find some/path -newer ~/date_start -and -not -newer ~/date_end
Advertisements

2 thoughts on “Using bash to find a file modified in a specific date/time interval?

  1. Good tip. If you have GNU date, you can do it without creating files:

    find some/path -newermt "13 october 2006 15:00:00" -and -not -newermt "14 october 2006 21:00:00"

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s