Linux – Understanding find with atime, ctime, and mtime

datefindlinux

So, I understand the difference between the three ideas in the title.

  1. atime — access time = last time file opened

  2. mtime — modified time = last time file contents was modified

  3. ctime — changed time = last time file inode was modified

So, presumably when I type something like

find ~/Documents -name '*.py' -type f -mtime 14

will find all match all files ending with .py which were modified in the last 2 weeks. Nothing shows up…

So I try

find ~/Documents -name '*.py' -type f -atime 1400

which should match anything opened within the last 1400 days (ending with .py and having type file) and still nothing.

Am I misunderstanding the documentation? Does it mean exactly 1400 days, for example?

A relevant post:

find's mtime and ctime options

Best Answer

Yes, -mtime 14 means exactly 14. See the top of that section in the GNU find manual (labelled "TESTS") where it says "Numeric arguments can be specified as [...]":

Numeric arguments can be specified as

+n     for greater than n,

-n     for less than n,

n      for exactly n.

Note that "less than" means "strictly less than", so -mtime -14 means "last modified at the current time of day, 13 days ago or less" and -mtime +14 means "last modified at the current time of day, 15 days ago or more".

Related Question