2013-12-13 17 views
7

voglio usare il comando find per trovare queste directory:comando Trova trovare le directory che sono stati creati dopo una certa data sotto 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') 

Questo è il comando mi sono imbattuto ma elenca ancora le directory più anziani:

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

Come modificare questa riga per trovare le directory create dopo tale data? Qual è la differenza tra -newerct e -newerBt. Penso di volere la data di nascita.

Nota: lo sto utilizzando con l'ultimo cygwin.

+0

Puoi mostrare un esempio di questo errore? Ecco l'output di una sessione Cygwin funzionante: http://pastebin.com/vAnf26dF (cygwin_nt-5.1/Windows XP su VirtualBox). – stv

risposta

3

Si potrebbe utilizzare stat invece:

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

Sei directory finding, ma mostrando file in esso contenuti.

Questi file possono avere date di nascita che si trovano prima di quello della directory che contiene. Ad esempio, crea un file, quindi una directory e sposta il file in quella directory.

Questa è la differenza tra data di nascita e data di modifica. Se un file viene spostato nella directory, la directory viene modificata, quindi penso che -newerct sia quello che vuoi.

+0

Ho corretto il mio esempio e ho riformulato la domanda. Non devo preoccuparmi dei timestamp dei file nella directory. Ma la directory ha bisogno di creare un timestamp dopo l'orario specificato. Quando eseguo 'stat' nella directory. Alcune directory compaiono prima della data che uso. Mi chiedo se sia una specie di bug cygwin. il "tempo di accesso" è successivo alla data specificata ma non alla data di "nascita" della directory. –

0

Mi chiedo se è un problema di fuso orario? Che cos'è echo $TZ? Cosa succede se esegui unset TZ (e unsetenv TZ, in csh) e riprova gli stessi comandi?

Ecco l'estratto di pagina man per -newerXY. Forse leggerlo farà scattare qualche pensiero?

-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. 
Problemi correlati