Hi, That sounds like the correct behaviour to me. It
sounds like you are expecting "newer" to mean
the-same-as-or-newer when it just means "newer" (i.e.
">=" rather than ">" as documented). The manual entry
says:

  -newer reference
    Time of the last data modification of the current file is more
    recent than that of the last data modification of the reference
    file.

  -newerXY reference
    Succeeds if timestamp X of the file being considered is newer than 
timestamp Y of the file reference.

It says "more recent than" and "newer". Both say "greater than" to me.

For what it's worth, my rawhide program (github.com/raforg/rawhide)
lets you do > or >= to get either behaviour.

But yes, if you need to match files dated at midnight
you will need to specify a timestamp earlier than
midnight in order for "newer" to include midnight. If
subsecond timestamps are checked by find, then you
might be better off using rawhide. Currently, it only
supports whole seconds, but the next version will
support nanoseconds. But that doesn't matter for your
needs because it can do ">=".

Although, are you sure that -newer considers the
nsec/subsecond part of the modified time? Have you
tested it? Maybe it does, but you didn't explicitly say
that you tested it. If it doesn't, then 11:59:59 would
be OK. But I suppose you probably did test it.

Actually, forget all that. Since you are using
-newermt, it just requires that find's time
specification notation supports nsec and it looks like
it does:

  
https://www.gnu.org/software/findutils/manual/html_mono/find.html#Date-input-formats

Shows this example:

  $ date --rfc-3339=ns  # --rfc-3339 is a GNU extension.
  2022-11-14 21:02:42.000000000-05:00

So maybe you can do:

  find . -newermt '2009-12-31 23:59:59.999999999-05:00'

adjusted for your own timezone. I just checked it and it worked. Yay!

  $ touch -m -d "2010-01-01 00:00:00" example.txt
  $ find example.txt -newermt '2009-12-31 23:59:59.999999999+11:00'
  example.txt

cheers,
raf

On Sun, Oct 12, 2025 at 01:55:28PM +0000, [email protected] wrote:

> find -newermt doesn't match files modified exactly at midnight. For
> example, find -newermt 2010-01-01 does not match a file dated
> 2010-01-01T00:00:00 with no subseconds.
> 
> Matching these files is necessary because some file systems have a low
> granularity so a file modified half a second after midnight in FAT32
> is still rounded down to a last modified time (mtime) 00:00:00. In
> addition, FAT32 only records dates, not times for last access time
> (atime), meaning in timezone +0000, all last access times are exactly
> midnight.
> 
> For these reasons, find -newermt should match files created exactly at
> midnight.
> 
> How to reproduce:
> 
> touch -m -d "2010-01-01 00:00:00" example.txt
> find example.txt -newermt 2010-01-01 # no match
> 
> The closest thing would be using 23:59:59 from the last day, but this
> would match files created in the last second before midnight on file
> systems with subsecond time granularity (such as ext4, exFAT, NTFS).
> 
> There currently seems to be no universal way to match all files
> created on a day including exactly on midnight.

Reply via email to