Chinaunix

标题: linux里查找目录中更改时间在指定日期以前的文件,要怎么写? [打印本页]

作者: wcx1985    时间: 2009-04-07 23:20
标题: linux里查找目录中更改时间在指定日期以前的文件,要怎么写?
linux里查找目录中更改时间在2009年3月1日以前的文件,要怎么写?
就是指定日期以前的文件,用find命令好像只能查找n天或n分钟以前的文件。
多谢!
作者: marsaber    时间: 2009-04-08 07:09
find / -mtime -5 -print   #五天内
find / -mtime +3 -print  #三天前
作者: kns1024wh    时间: 2009-04-09 21:32
标题: 回复 #1 wcx1985 的帖子
man find
mtime参数就是可以的
find / -mtime  +/-数字 执行之前或之后的几天
作者: icykiss    时间: 2012-07-05 17:56
find 有一个-newer参数,它还有一个用法:find /tmp -newerct 120701,还有-newermt、-neweratg两个,同时你还可以用叹号反转查找:find /tmp ! -newerct 120505这样。
作者: icykiss    时间: 2012-07-05 17:59
icykiss 发表于 2012-07-05 17:56
find 有一个-newer参数,它还有一个用法:find /tmp -newerct 120701,还有-newermt、-neweratg两个,同时你 ...

对了,还有一个方法的,就是你可以先用touch命令建一个120101时间的文件,再用-newer去比较它来查找也是没有问题的。
作者: ulovko    时间: 2012-07-05 18:02
icykiss 发表于 2012-07-05 17:56
find 有一个-newer参数,它还有一个用法:find /tmp -newerct 120701,还有-newermt、-neweratg两个,同时你 ...


真心学习了,没想到 还有这个参数 thx ^_^
  1. -newerXY file
  2.              True if the current file has a more recent last access time
  3.              (X=a), inode creation time (X=B), change time (X=c), or modifica‐
  4.              tion time (X=m) than the last access time (Y=a), inode creation
  5.              time (Y=B), change time (Y=c), or modification time (Y=m) of
  6.              file.  In addition, if Y=t, then file is instead interpreted as a
  7.              direct date specification of the form understood by cvs(1).  Note
  8.              that -newermm is equivalent to -newer.
复制代码

作者: ulovko    时间: 2012-07-05 18:04
icykiss 发表于 2012-07-05 17:59
对了,还有一个方法的,就是你可以先用touch命令建一个120101时间的文件,再用-newer去比较它来查找也是没 ...

这个方法也不错的! ^_^
作者: snow888    时间: 2012-07-05 22:16
俺也是第一次知道还能这样写,thx




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2