Linux – 在特定文件之前和之后查找文件

我试图find我的计算机上创build一个特定的文件前1小时和1小时后创build的文件。

这是我试过的方法 –

find /root -newermt "2012-10-04 1800" -and -newermt "2012-10-04 2000" -exec ls -ldb {} \; 

我的linux上的目录是root,创build​​的特定文件是在19:00创build的

这是另一种方法,我试过哪些工作,但它只显示一个结果之后或之前不是两个! >

 find /root/Downloads -type f \( -newer /root/Downloads/alex.txt ! -newer /root/Downloads/hesham.txt \) 

你要:

 # missing a -not here ---------------------v find /root -newermt "2012-10-04 1800" -and -not -newermt "2012-10-04 2000" -exec ls -ldb {} \; 

这样做:

  1. /root所有文件
  2. “2012-10-04 1800”
  3. 并不“2012-10-04 2000” (或比“2012-10-04 2000”大

这可能不是最有效的解决方案,但..

touch / tmp / temp -t文件创建时间 – 1小时

touch / tmp / ntemp -t文件创建时间+ 1小时

找 。 -newer / tmp / temp -a! -newer / tmp / ntemp -exec ls -l {} \; 2>的/ dev / null的