find -mtime +N/-N/N

In unix or linux environment often used such wording find -mtime to find the file before a certain point in time, as to how to write find -mtime + N / -N / N, that it is not very clear, today, to find some look at data, painted this chart to understand and remember:

As can be seen from the figure, since the beginning of the current time point, + indicates left, the starting point of time and then to push earlier, may be referred to outside xx; - represents right, counting from the time point to after the push time, it may be referred to within XX; accordingly had no minus sign denotes the N-th day. Therefore:
We look at this example:
My current time at 22:31 on March 1st, 2011, I have the following documents:

E:\testpath>ls -l

Total 0
-rwxrwxrwa   1 Administrator   None                  0 Feb 25 22:37 111.txt
-rwxrwxrwa   1 Administrator   None                  0 Feb 26 22:38 222.txt
-rwxrwxrwa   1 Administrator   None                  0 Feb 27 22:38 333.txt
-rwxrwxrwa   1 Administrator   None                  0 Feb 28 22:01 444.txt
-rwxrwxrwa   1 Administrator   None                  0 Feb 28 22:30 555.txt
- rwxrwxrwa . 1 Administrator   None 0 -Mar . 1 22 is : 31 is 666.txt < - time of the current file                        
-rwxrwxrwa   1 Administrator   None                  0 Mar  2  2011 777.txt

-mtime +2, represent other than two days, that is, begin to run from two days of the current time (2011-03-01 22:31) before, to an earlier time goes on. Therefore, the two days of the current time distance: 2011-02-27 22:31, in the previous document, will be elected. 

-mtime +1, represent other than one day, that is, from the current time from the date of the day before, to an earlier time goes on. So the file before 2011-02-28 22:31 belong to the result, the file does not belong to the result 2011-02-28 22:31:

-mtime 2, the current time from the second day of the file, the current time is 22:31 2011-03-01, 2011-02-27 push forward 22:31 on day 2, so as a point in time 24 hours within the time as 2011-02-2722: 31 to 2011-02-28 22:31, so the file within this time will be selected out:

1 -mtime, the current time from the file on Day 1, the current time 2011-03-01 22:31, 1 day pushed forward 2011-02-28 22:31, so as a point in time 24 hours within the time as 2011-02-2822: 31 to 22:31 2011-03-01, so the file within this time will be selected out:

-mtime -1 represents less than 1 day for 2011-02-28 22:31, right from the current transition time from one day:

-mtime -2 represent less than 2 days, is 2011-02-27 22:31 starting from two days from the current time, the right goes:

(Turn) https://oracleblog.org/study-note/how-to-calculate-find-mtime/

Guess you like

Origin www.cnblogs.com/dahaoran/p/11090122.html