Follow-up Comment #7, bug #23065 (group findutils):

Let first check what really happens.


Create 25 files with timestamps from now going back in 2 hour steps.

$ mkdir d \
    && cd d \
    && t=$( date '+%s' ) \
    && date -d@$t
Sun Jun 14 04:03:48 PM CEST 2026

$ for f in $( seq 25 ); do
    touch -d@$t $t
    let t-=7200
  done \
  && ls -logd *
-rw-r--r-- 1 0 Jun 12 16:03 1781273028
-rw-r--r-- 1 0 Jun 12 18:03 1781280228
-rw-r--r-- 1 0 Jun 12 20:03 1781287428
-rw-r--r-- 1 0 Jun 12 22:03 1781294628
-rw-r--r-- 1 0 Jun 13 00:03 1781301828
-rw-r--r-- 1 0 Jun 13 02:03 1781309028
-rw-r--r-- 1 0 Jun 13 04:03 1781316228
-rw-r--r-- 1 0 Jun 13 06:03 1781323428
-rw-r--r-- 1 0 Jun 13 08:03 1781330628
-rw-r--r-- 1 0 Jun 13 10:03 1781337828
-rw-r--r-- 1 0 Jun 13 12:03 1781345028
-rw-r--r-- 1 0 Jun 13 14:03 1781352228
-rw-r--r-- 1 0 Jun 13 16:03 1781359428
-rw-r--r-- 1 0 Jun 13 18:03 1781366628
-rw-r--r-- 1 0 Jun 13 20:03 1781373828
-rw-r--r-- 1 0 Jun 13 22:03 1781381028
-rw-r--r-- 1 0 Jun 14 00:03 1781388228
-rw-r--r-- 1 0 Jun 14 02:03 1781395428
-rw-r--r-- 1 0 Jun 14 04:03 1781402628
-rw-r--r-- 1 0 Jun 14 06:03 1781409828
-rw-r--r-- 1 0 Jun 14 08:03 1781417028
-rw-r--r-- 1 0 Jun 14 10:03 1781424228
-rw-r--r-- 1 0 Jun 14 12:03 1781431428
-rw-r--r-- 1 0 Jun 14 14:03 1781438628
-rw-r--r-- 1 0 Jun 14 16:03 1781445828


Now find all file within the 1-day range of "1 day before now: "-mtime 1".

$ find -type f -mtime 1 -exec ls -logd '{}' +
-rw-r--r-- 1 0 Jun 12 18:03 ./1781280228
-rw-r--r-- 1 0 Jun 12 20:03 ./1781287428
-rw-r--r-- 1 0 Jun 12 22:03 ./1781294628
-rw-r--r-- 1 0 Jun 13 00:03 ./1781301828
-rw-r--r-- 1 0 Jun 13 02:03 ./1781309028
-rw-r--r-- 1 0 Jun 13 04:03 ./1781316228
-rw-r--r-- 1 0 Jun 13 06:03 ./1781323428
-rw-r--r-- 1 0 Jun 13 08:03 ./1781330628
-rw-r--r-- 1 0 Jun 13 10:03 ./1781337828
-rw-r--r-- 1 0 Jun 13 12:03 ./1781345028
-rw-r--r-- 1 0 Jun 13 14:03 ./1781352228
-rw-r--r-- 1 0 Jun 13 16:03 ./1781359428

--> OK: it lists all files in the range from now-2d to now-1d.

Now the same with -daystart.

$ find -daystart -type f -mtime 1 -exec ls -logd '{}' +
-rw-r--r-- 1 0 Jun 13 00:03 ./1781301828
-rw-r--r-- 1 0 Jun 13 02:03 ./1781309028
-rw-r--r-- 1 0 Jun 13 04:03 ./1781316228
-rw-r--r-- 1 0 Jun 13 06:03 ./1781323428
-rw-r--r-- 1 0 Jun 13 08:03 ./1781330628
-rw-r--r-- 1 0 Jun 13 10:03 ./1781337828
-rw-r--r-- 1 0 Jun 13 12:03 ./1781345028
-rw-r--r-- 1 0 Jun 13 14:03 ./1781352228
-rw-r--r-- 1 0 Jun 13 16:03 ./1781359428
-rw-r--r-- 1 0 Jun 13 18:03 ./1781366628
-rw-r--r-- 1 0 Jun 13 20:03 ./1781373828
-rw-r--r-- 1 0 Jun 13 22:03 ./1781381028


--> also OK: is lists all files of Jun 13.
This means -daystart moved the 1-day window for -mtime to midnight.

Now list all files which are younger than the 1-day range.


$ find -type f -mtime -1 -exec ls -logd '{}' +
-rw-r--r-- 1 0 Jun 13 18:03 ./1781366628
-rw-r--r-- 1 0 Jun 13 20:03 ./1781373828
-rw-r--r-- 1 0 Jun 13 22:03 ./1781381028
-rw-r--r-- 1 0 Jun 14 00:03 ./1781388228
-rw-r--r-- 1 0 Jun 14 02:03 ./1781395428
-rw-r--r-- 1 0 Jun 14 04:03 ./1781402628
-rw-r--r-- 1 0 Jun 14 06:03 ./1781409828
-rw-r--r-- 1 0 Jun 14 08:03 ./1781417028
-rw-r--r-- 1 0 Jun 14 10:03 ./1781424228
-rw-r--r-- 1 0 Jun 14 12:03 ./1781431428
-rw-r--r-- 1 0 Jun 14 14:03 ./1781438628
-rw-r--r-- 1 0 Jun 14 16:03 ./1781445828


--> OK: it lists all files from now-1d to now.

The same with -daystart.

$ find -daystart -type f -mtime -1 -exec ls -logd '{}' +
-rw-r--r-- 1 0 Jun 14 00:03 ./1781388228
-rw-r--r-- 1 0 Jun 14 02:03 ./1781395428
-rw-r--r-- 1 0 Jun 14 04:03 ./1781402628
-rw-r--r-- 1 0 Jun 14 06:03 ./1781409828
-rw-r--r-- 1 0 Jun 14 08:03 ./1781417028
-rw-r--r-- 1 0 Jun 14 10:03 ./1781424228
-rw-r--r-- 1 0 Jun 14 12:03 ./1781431428
-rw-r--r-- 1 0 Jun 14 14:03 ./1781438628
-rw-r--r-- 1 0 Jun 14 16:03 ./1781445828

--> OK: it lists only the ones which are younger than the daystart.

Also -mtime 0 is correct for both with and without -daystart:

$ find -type f -mtime 0 -exec ls -logd '{}' +
-rw-r--r-- 1 0 Jun 13 18:03 ./1781366628
-rw-r--r-- 1 0 Jun 13 20:03 ./1781373828
-rw-r--r-- 1 0 Jun 13 22:03 ./1781381028
-rw-r--r-- 1 0 Jun 14 00:03 ./1781388228
-rw-r--r-- 1 0 Jun 14 02:03 ./1781395428
-rw-r--r-- 1 0 Jun 14 04:03 ./1781402628
-rw-r--r-- 1 0 Jun 14 06:03 ./1781409828
-rw-r--r-- 1 0 Jun 14 08:03 ./1781417028
-rw-r--r-- 1 0 Jun 14 10:03 ./1781424228
-rw-r--r-- 1 0 Jun 14 12:03 ./1781431428
-rw-r--r-- 1 0 Jun 14 14:03 ./1781438628
-rw-r--r-- 1 0 Jun 14 16:03 ./1781445828
$ find -daystart -type f -mtime 0 -exec ls -logd '{}' +
-rw-r--r-- 1 0 Jun 14 00:03 ./1781388228
-rw-r--r-- 1 0 Jun 14 02:03 ./1781395428
-rw-r--r-- 1 0 Jun 14 04:03 ./1781402628
-rw-r--r-- 1 0 Jun 14 06:03 ./1781409828
-rw-r--r-- 1 0 Jun 14 08:03 ./1781417028
-rw-r--r-- 1 0 Jun 14 10:03 ./1781424228
-rw-r--r-- 1 0 Jun 14 12:03 ./1781431428
-rw-r--r-- 1 0 Jun 14 14:03 ./1781438628
-rw-r--r-- 1 0 Jun 14 16:03 ./1781445828


FWIW: this means that '-mtime -1' is (almost) the same as '-mtime 0',
which is actually logically correct: everything newer than the 1-day range
since yesterday is the same as the current day range.
I wrote "almost" because I expect that '-mtime 0' would skip files which
have an mtime with the exact oldest second of that day range compared to
'-mtime -1'.

Now to the documentation:

The manpage only mentions the first sentence of the following Texinfo manual
snippet:


Measure times from the beginning of today rather than from 24 hours ago.
So, to list the regular files in your home directory that were modified
yesterday, do
  find ~/ -daystart -type f -mtime 1
[...]


Looking at the above examples, this description is correct, and describes how
'find -daystart' works.

I think the problem to understand this option is that it just moves the 1-day
window used by -mtime.  But - as I'm a non-native English speaker - I have no
better wording.  Anyone?

P.S. I didn't check on -mmin etc. yet, but to me -mtime looks good with and
without the -daystart option.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?23065>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to