2013-12-13 99 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.