I am trying to find a file that are 0 days old. Below are the steps I performed to test this
$ ls
$ ls -ltr
total 0
$ touch tmp.txt
$ ls -ltr
total 0
-rw-r----- 1 tstUser tstUser 0 Feb 28 20:02 tmp.txt
$ find * -mtime 0
$
$ find * -mtime -1
tmp.txt
$
Why is ‘-mtime 0’ not getting me the file?
What is the exact difference between ‘-mtime 0’ and ‘-mtime -1’?
Im sure there must be other ways to find files that are 0 days old in unix, but im curious in understanding how this ‘-mtime’ actually works.
So, -mtime 0 would be equal to: “File’s data was last modified 0 hours ago.
While -mtime 1 would be: “File’s data was last modified 24 hours ago”
Edit:
So I guess -1 would be modified within the last 24 hours, while 1 would be exactly one day.