最近写脚本的时候遇到了这个-mtime n的参数,其实也不是很难!以下是我的一些拙见,若有不准确的地方还望大家指正!
find命令有个参数是-mtime n,man手册里解释的还算清楚,下面是我的总结!
-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.这个解释我觉着不是很准确,我理解的字面的意思是n天之前,应该理解为今天之前的第n天!
Numeric arguments can be specified as
+n for greater than n,
-n for less than n,
n for exactly n.
find /root/Desktop/ -mtime 1 找出桌面文件中,哪些是在今天之前1天的文件内容被修改过的文件
find /root/Desktop/ -mtime +1 找出桌面文件中,哪些是在今天之前1天之前的文件内容被修改过的文件
find /root/Desktop/ -mtime -1 找出桌面文件中,哪些是在今天之前1天之后的文件内容被修改过的文件
同类命令atime,-ctime,-mmin,-cmin,-amin也都是这样的!
-atime n
File was last accessed n*24 hours ago. When find figures out how many
24-hour periods ago the file was last accessed, any fractional part is
ignored, so to match -atime +1, a file has to have been accessed at least
two days ago.
-amin n
File was last accessed(使用,访问过的) n minutes ago.
ctime n
File’s status was last changed n*24 hours ago. See the comments for
-atime to understand how rounding affects the interpretation of file sta-
tus change times.
-cmin n
File’s status was last changed n minutes ago.
-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.
-mmin n
File’s data was last modified n minutes ago.
atime:访问使用过 ctime:文件状态改变 mtime:文件内容被修改过
这三种情况怎么区分,需要好好的体会