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 - linux find recently modified files - unix find files created today - linux find modified files - linux find files changed today - unix find files modified today - linux find all files modified today - find last modified files linux - find last modified files - find modified files linux - linux find files recently modified - linux find last modified files - linux find changed files - linux find date modified - find files today - unix find date modified - find latest modified files in unix - linux find files modified since - find files modified today linux - find files changed today linux - linux find last modified - find recently modified files linux - unix files modified today - find modified date linux - find files modified today - linux find files modified in last day - unix find files by date - linux find modified since - find mtime 1 hour - linux find files modified - unix find recent files - unix find by date modified - find recent files unix - find files modified in last hour - find command modified date - find files modified since - find modified files - linux find files modified date - unix find all files modified today - linux find files last modified - Uinx find files modified last hour - windows 2003 search files modified time - linux ls last modified - linux last modified files - linux find file modified - unix find time - linux find files modified after date - linux find by date modified - linux find files by modified date - unix Find most recent file -