Unix find -mtime {a negative or postive value}

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 21:33:38

问题


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


回答1:


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.




回答2:


Well, I can.

-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

find . -mtime 0   # find files modified between now and 1 day ago
                  # (i.e., within the past 24 hours)
find . -mtime -1  # find files modified less than 1 day ago
                  # (i.e., within the past 24 hours, as before)
find . -mtime 1   # find files modified between 24 and 48 hours ago
find . -mtime +1  # find files modified more than 48 hours ago


来源:https://stackoverflow.com/questions/27700943/unix-find-mtime-a-negative-or-postive-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!