2013-12-13 104 views
7

我想用find命令在特定日期后的建立是为了找到这些目录,目录:查找命令找到在Linux/Cygwin的

Access: 2013-12-13 10:59:46.190886900 -0500 
Modify: 2013-12-03 07:04:02.995890600 -0500 
Change: 2013-12-03 07:04:02.995890600 -0500 
Birth: 2013-12-02 07:04:02.000000000 -0500 (I want a time after '12-03') 

这是我跑的命令,但它仍然列出旧目录:

find . -type d -newerBt '2013-12-03 00:00:00' -exec du -h {} \; 

如何修改此行以查找在该日期之后创建的目录? -newerct和-newerBt有什么区别?我想我想要出生日期。

注意:我正在运行最新的cygwin。

+0

你能举一个这个失败的例子吗?以下是Cygwin会话的输出:http://pastebin.com/vAnf26dF(Cygwin_nt-5.1/VirtualBox上的Windows XP)。 – stv

回答

3

你可以使用统计代替:

find . -type d -exec bash -c '(($(stat -c %W "{}") > $(date +%s -d '2013-12-03'))) && du -h "{}"' \; 
1

你是finding目录,但显示其中包含的文件。

那些文件可能有之前的包含目录的出生日期。例如,创建一个文件,然后创建一个目录,然后将该文件移动到该目录中。

这是出生日期和更改日期之间的差异。如果一个文件移动到目录中,目录改变了,所以我认为-newerct是你想要的。

+0

我纠正了我的例子,并重写了这个问题。我不需要担心目录中文件的时间戳。但是在我指定的时间之后,该目录需要一个创建时间戳。当我在目录上运行“stat”时。有些目录出现在我使用的日期之前。我不知道它是否是某种cygwin错误。 “访问时间”是在我指定的日期之后,但不是目录的“出生”日期。 –

0

我不知道这是一个时区的问题?什么是echo $TZ?如果你做unset TZ(和unsetenv TZcsh),会发生什么情况并重新尝试相同的命令?

下面是-newerXY的手册页摘录。也许读它会引发一些想法?

-newerXY reference 
      Compares the timestamp of the current file with reference. The reference 
      argument is normally the name of a file (and one of its timestamps is used 
      for the comparison) but it may also be a string describing an absolute time. 
      X and Y are placeholders for other letters, and these letters select which 
      time belonging to how reference is used for the comparison. 

      a The access time of the file reference 
      B The birth time of the file reference 
      c The inode status change time of reference 
      m The modification time of the file reference 
      t reference is interpreted directly as a time 

      Some combinations are invalid; for example, it is invalid for X to be t. 
      Some combinations are not implemented on all systems; for example B is not 
      supported on all systems. If an invalid or unsupported combination of XY is 
      specified, a fatal error results. Time specifications are interpreted as for 
      the argument to the -d option of GNU date. If you try to use the birth time 
      of a reference file, and the birth time cannot be determined, a fatal error 
      message results. If you specify a test which refers to the birth time of 
      files being examined, this test will fail for any files where the birth time 
      is unknown.