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.
Related Articles
- Change Group Ownership of Symbolic Links in Unix or Linux
- Refresh Linux or Unix Path Environmental Variables with rehash
- How to Make or Create Symbolic Link in Unix or Linux
- How to Mount USB Disk Drive in UNIX or Linux
- (Enhance) Concurrent Capable and Big vg Format Volume Group in AIX Unix
- Backup Changed Files with CopyChangedFiles
- How to Disable Linux and Unix Cron Jobs (Crontab) Email Sending
- How to Calculate and Generate MD5 Hash Value in Linux and Unix with md5sum
- How to Change or Spoof MAC Address in Windows XP, Vista, Server 2003/2008, Mac OS X, Unix and Linux
- Search and Find All Files including Hidden and System Files










































June 30th, 2009 06:53
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?
June 11th, 2009 15:46
@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.
June 4th, 2009 21:02
Good one. Thanks.
Tried
find . -mtime -0.041666667 -print
on Debian, it throws an error
“find: invalid argument `-0.041666667′ to `-mtime’”
June 4th, 2009 20:02
Additionally, to find files modified less than an hour ago:
find . -mtime -0.041666667 -printSimply 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
May 14th, 2009 16:00
thanks a lot for the good article.
February 20th, 2009 21:22
It was of timely help
Thanks.
December 12th, 2008 20:36
And how you will find files by specified hour?
example. Files modified in last 8hours, if now, the time is 01AM
November 12th, 2008 21:08
Thanks!!
October 1st, 2008 04:19
[...] be useful when I’m syncing files from our dev server to our production server. And thanks to this post I’ve finally found [...]
June 30th, 2008 11:46
[...] References: http://www.mydigitallife.info/2006/01/19/find-files-that-are-modified-today-or-since-certain-time-ag... [...]
May 7th, 2008 15:35
Very good article, thanx!
August 4th, 2007 08:59
Great Thnks!