Linux - Find last modified fie from N day


Below is a very handy find command to look for log files that is last modified N day.
find /path/to/ -type f -mtime +7 -name '*.log' 
where

-mtime n
              File's data was last modified n*24 hours ago.  See the comments for -atime to understand how rounding affects the interpretation of file modification times.

-type c
              File is of type c:

              b      block (buffered) special

              c      character (unbuffered) special

              d      directory

              p      named pipe (FIFO)

              f      regular file

              l      symbolic link; this is never true if the -L option or the -follow option is in effect, unless the symbolic link is broken.  If you  want  to  search  for  symbolic
                     links when -L is in effect, use -xtype.

              s      socket

              D      door (Solaris)



Note the other interesting options too


-atime n
              File was last accessed n*24 hours ago.  When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match  -atime
              +1, a file has to have been accessed at least two days ago.

-ctime n
              File's status was last changed n*24 hours ago.  See the comments for -atime to understand how rounding affects the interpretation of file status change times.


-amin n
              File was last accessed n minutes ago.

-cmin n
              File's status was last changed n minutes ago.

-mmin n
              File's data was last modified n minutes ago.


Comments

Popular Posts