Find Files that are Modified Today (or Since Certain Time Ago) in Unix

To find all files that was modified since a specific time ago (i.e an hour ago, a day ago, 24 hours ago, a weeks ago and so on) in Unix environment, the find command will come in handy. The command syntax is:

To find all files modified in the last 24 hours (last full day) in current directory and its sub-directories:

find . -mtime -1 -print

Flag -mtime -1 option tells find command to look for files modified in the last day (24 hours). Flag -print option will cause find command to print the files’ location. -print can be replaced with -ls if you want a directory-listing-type response.

To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:

find /directory_path -mtime -1 -print

The command is basically the same with the earlier command, just that now you no need to cd (change directory) to the directory you want to search.

To find all files with regular file types only, and modified in the last 24 hours (last full day) in current directory and its sub-directories:

find /directory_path -type f -mtime -1 -print

To find all files that are modified today only (since start of day only, i.e. 12 am), in current directory and its sub-directories:

touch -t `date +%m%d0000` /tmp/$$
find /tmefndr/oravl01 -type f -newer /tmp/$$
rm /tmp/$$

The first command can be modified to specify other date and time, so that the commands will return all files that have changed since that particular date and time.


12 Responses to “Find Files that are Modified Today (or Since Certain Time Ago) in Unix”

  1. Mike
    June 30th, 2009 06:53
    12

    Question: If one does a find for files modified in the last two minutes, and it takes the command ten minutes to complete, is that going to fail completely?

  2. Bruno De Barros
    June 11th, 2009 15:46
    11

    @Kiran Kappeta, it works for me on Ubuntu. Try to see if it supports any non-integer values at all (for example, try 0.5 or 0.25). If it doesn’t, there’s your problem.

  3. Kiran Kappeta
    June 4th, 2009 21:02
    10

    Good one. Thanks.

    Tried

    find . -mtime -0.041666667 -print

    on Debian, it throws an error
    “find: invalid argument `-0.041666667′ to `-mtime’”

  4. Bruno De Barros
    June 4th, 2009 20:02
    9

    Additionally, to find files modified less than an hour ago:
    find . -mtime -0.041666667 -print

    Simply divide 1 by 24 (24 hours) and you’ll get what you want. For example, 0.1 is 2 hours and 24 minutes.

    I hope this helps whoever needs to find files modified LESS than one full day ago. :)

    —–
    Bruno De Barros

  5. Susmita
    May 14th, 2009 16:00
    8

    thanks a lot for the good article.

  6. Prabhakar
    February 20th, 2009 21:22
    7

    It was of timely help :)
    Thanks.

  7. RuBiCK
    December 12th, 2008 20:36
    6

    And how you will find files by specified hour?

    example. Files modified in last 8hours, if now, the time is 01AM

  8. Deiby
    November 12th, 2008 21:08
    5

    Thanks!!

  9. Recently Modified Files : mnavasca.ca
    October 1st, 2008 04:19
    4

    [...] be useful when I’m syncing files from our dev server to our production server. And thanks to this post I’ve finally found [...]

  10. Finding files modified since a certain time « Tech Notes @ Fernvale
    June 30th, 2008 11:46
    3

    [...] References: http://www.mydigitallife.info/2006/01/19/find-files-that-are-modified-today-or-since-certain-time-ag... [...]

  11. einstein
    May 7th, 2008 15:35
    2

    Very good article, thanx!

  12. iPAS
    August 4th, 2007 08:59
    1

    Great Thnks!

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

linux find files modified today - unix find files modified today - find files modified today - unix find recent files - linux find files created today - linux find modified - unix find files created today - find files created today - linux find last modified files - unix find mtime - linux find last modified - unix list files by date - find modified - linux find modified files - find last modified - unix file date - unix find last modified - linux find files modified - linux find changed files - linux find modified date - unix find files modified since - unix find files by date - linux find last modified file - unix find today - find files changed today - unix find files changed today - find modified time - linux find files modified date - unix find file by date - all - unix file modified time - linux find date modified - unix find hours - list files by date in unix - find modified files - find files modified today linux - find files created today linux - unix find modified today - unix find last modified files - find recent files unix - unix find modified date - unix find file date - linux find last changed files - linux last modified files - unix find files today - last modified file in unix - unix file modified date - Linux find files modified by date - linux find all files modified today - find last modified files linux - find modified today - find last modified files - unix modified date - UNIX find date - unix find files modified - unix find file modified today - linux find by modified date - linux find files modified on date - linux find modified today - UNIX last modified date - linux find files date modified - find last modified file linux - find mtime hours - unix find hour - find modified date - find last modified file unix - unix file modification date - unix find all files modified today - unix find by date - unix get file date - find files time - file modified date unix - linux list files created today - find changed files - linux find files changed since -