• UNIX – Find Files that Changed Within Time Window

    Every so often us lowly UNIX admins find ourselves needing to search a file system for files that have been created or changed within a certain time window. In other words, those files that are newer than time “X”, but not newer than time “Y”. There are a number of ways to accomplish this, but my preferred method is to create two reference files to indicate the beginning and end of my window and use the “-newer” and “! -newer” flags to search for files that changed within that window.

    # touch -amt 200910260000 /tmp/starttime
    # touch -amt 200910262359 /tmp/endtime
    # find / -type f -newer /tmp/starttime -a ! -newer /tmp/endtime

    The guys at virtuelvis.com point out that it is more elegant to accomplish this without creating two files, but their solution does not work with operating systems that use strict POSIX compliant “find” implementations, making it of little use in some cases. For the curious, here is their example:

    # find . -type f -newermt 2009-10-26 ! -newermt 2009-10-27

    This entry was posted on Monday, November 2nd, 2009 at 11:57 am and is filed under Data and Technology. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
  • 0 Comments

    Take a look at some of the responses we've had to this article.

  • Leave a Reply

    Let us know what you thought.

  • Name (required):

    Email (required):

    Website:

    Message:

Visitors have tagged this post: find files newer than (6) - unix find time (2) - unix find newermt (2) - posix files \"newer than\ (2) - unix find files by time (2) - finding files that are not of a user in UNIX (2) - find files from time (1) - unix exemple touch -r (1) - example find -atime unix (1) - unix -nt newer than (1) - unix find \"-newer\ solaris 10 (1) - bash find newermt (1) - finding files newer than a data in unix (1) - find not newer than (1) - unix solaris find prune example (1) - bash find file newer than certain time (1) - unix list file that have changed (1) - find changed files solaris 10 (1) - unix find newer example (1) - unix file within 1 year (1) - find newermt (1) - Unix \"find files created\ (1) - solaris find time example -ctime (1) - find files newer than specific time (1) - find file in unix newer than some time (1) - \"-type f ! -newer\ (1) - bash list files newer than (1) - how to find file on unix sort time (1) - UNIX find files not touched (1) - unix find time window (1) - touch -r unix examples (1) - linux \"find files created between\ (1) - find files newer than a time (1) - unix check directory changed time (1) - find file newer than (1) - unix find file by time (1) - find examples window unix (1) - unix find . -user (1) - unix find . -exec touch {} \\; (1) - find newer touch (1) - unix find newer (1) - find time newer (1) - unix \"find . -type f -newer\ (1) - solaris copy file within allowed time (1) - Unix find files newer than example (1) - find files between certain times (1) - find files newer than time (1) - solaris find files created between time (1) - unix find * prune (1) - Solaris 10 \"find files\ (1) - find . files newer (1) - unix find between times (1) - solaris find time newer (1) - solaris find time (1) - example unix touch -t (1) - find files and touch them unix (1) - bash find files newer than (1) - newer in unix (1) - unix find * -prune -mtime (1) - sort -t, 1 -2 unix example (1) - unix find file between time (1) -