unixgnu-findutils

Unix find -mtime {a negative or postive value}


What do find -mtime -4 and find -mtime +4 do? I cannot understand the examples given in the man page.


Solution

  • As per man page:

    -mtime n
        File’s  data was last modified n*24 hours ago.  See the comments
        for -atime to understand how rounding affects the interpretation
        of file modification times.
    

    The argument to -mtime is interpreted as the number of whole days in the age of the file. -mtime +n means strictly greater than, -mtime -n means strictly less than.

    So in your case,

    -4 meaning less than 4 days.
    +4 meaning more than 4 days i.e. 4*24 hours.