13

My question is:

How to find files that has been modified from a given date(specifying the exact hour) to another given date(specifying the exact hour) in a given directory, from / for example.

I think that can be achieved with find.

Does anyone know how to do this¿? Thank you in advance

30

go for this one:

find . -newermt "2013-01-01 00:00:00" ! -newermt "2013-01-02 00:00:00"

m The modification time of the file reference

t reference is interpreted directly as a time

| improve this answer | |
  • Nice shot. Allowed me to get which application created that big '~/.m2' dir by looking in /usr/bin based on the date and time! It's guacamole/freerdp. – tuk0z Apr 23 '16 at 10:07
  • Instead of !, you may use -not to increase readability and compatibility with all shell types (bash, zsh, etc.). – jiun Oct 17 '19 at 3:41
  • Using -not instead of ! may avoid problems with some shells, but it isn’t POSIX-compliant, so it won’t work on all versions of Unix. – G-Man Says 'Reinstate Monica' Dec 20 '19 at 3:59
3

The basic structure of the find command looks like this:

# find <paths> <filters> <actions>

find / -mtime -10 -mtime +4

find has + and - operators that work with the mtime, atime and ctime options:

atime == Access Time
mtime == Modified Time
ctime == Change Time

You can read inode with -*time and define intervals for your times via + and/or -

| improve this answer | |
  • (1) Specifying modification time limits to the granularity of an exact hour seems to be a major focus of this question.   This answer doesn’t even mention that.   (2) This answer copies most of an earlier answer, and adds very little explanation. – G-Man Says 'Reinstate Monica' Dec 20 '19 at 4:17
-2

I think you can do it with below:

find ./* -mtime -10 -mtime +4 -ls
| improve this answer | |
  • 1
    For based on hrs and min You need to find the numbers mins -- from and to, to be used in below: find ./* -mmin -540 -mmin +20 -ls – Pankaj Feb 20 '15 at 11:48
  • You can edit your onw posts to improve them with relevant information. Keep the comments for more non-essential stuff. – Anthon Feb 20 '15 at 12:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.