GNU/Linux >> Tutoriales Linux >  >> Linux

Encuentra archivos creados entre un rango de fechas

Si usa GNU find , desde la versión 4.3.3 puedes hacer:

find -newerct "1 Aug 2013" ! -newerct "1 Sep 2013" -ls

Aceptará cualquier cadena de fecha aceptada por GNU date -d .

Puedes cambiar el c en -newerct a cualquiera de a , B , c o m para ver atime/birth/ctime/mtime.

Otro ejemplo:enumere los archivos modificados entre las 17:30 y las 22:00 del 6 de noviembre de 2017:

find -newermt "2017-11-06 17:30:00" ! -newermt "2017-11-06 22:00:00" -ls

Detalles completos de man find :

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

Puede usar lo siguiente para encontrar lo que necesita.

Encuentra archivos anteriores a una fecha/hora específica:

find ~/ -mtime $(echo $(date +%s) - $(date +%s -d"Dec 31, 2009 23:59:59") | bc -l | awk '{print $1 / 86400}' | bc -l)

O puede buscar archivos entre dos fechas. Primera fecha más reciente, última fecha, más antigua. Puede bajar al segundo y no tiene que usar mtime. Puedes usar lo que necesites.

find . -mtime $(date +%s -d"Aug 10, 2013 23:59:59") -mtime $(date +%s -d"Aug 1, 2013 23:59:59")

Algunas buenas soluciones aquí. Quería compartir el mío, ya que es breve y simple.

Estoy usando find (GNU findutils) 4.5.11

$ find search/path/ -newermt 20130801 \! -newermt 20130831

Pruebe el siguiente comando:

find /var/tmp -mtime +2 -a -mtime -8 -ls

Esto le permitirá encontrar archivos en /var/tmp carpeta que es anterior a 2 días pero no mayor de 8 días.


Linux
  1. Linux:¿cómo encontrar la fecha de creación del archivo?

  2. ¿Cómo enumerar los archivos que se cambiaron en un cierto intervalo de tiempo?

  3. Linux:¿cómo eliminar archivos creados entre dos veces?

  4. ¿Cómo obtener solo archivos creados después de una fecha con Ls?

  5. ¿Es posible transferir archivos en un rango de fechas a través de FTP?

Cómo encontrar recursivamente y enumerar los archivos por fecha en Linux

Cómo encontrar la fecha y hora exactas de instalación de su sistema operativo Linux

Cómo encontrar la fecha y hora de instalación del sistema operativo Linux

¿El indicador de hora no muestra la fecha/hora?

Buscar y eliminar archivos con una fecha específica

Linux:uso de buscar para localizar archivos anteriores a <fecha>