How do I use the UNIX command find
to search for files created on a specific date?
9 Answers
As pointed out by Max, you can't, but checking files modified or accessed is not all that hard. I wrote a tutorial about this, as late as today. The essence of which is to use -newerXY
and ! -newerXY
:
Example: To find all files modified on the 7th of June, 2007:
$ find . -type f -newermt 2007-06-07 ! -newermt 2007-06-08
To find all files accessed on the 29th of september, 2008:
$ find . -type f -newerat 2008-09-29 ! -newerat 2008-09-30
Or, files which had their permission changed on the same day:
$ find . -type f -newerct 2008-09-29 ! -newerct 2008-09-30
If you don't change permissions on the file, 'c' would normally correspond to the creation date, though.

- 7,816
- 2
- 24
- 35

- 4,112
- 1
- 16
- 4
-
7My version of find (GNU 4.2.32) doesn't seem to support the -newerXY predicates. Is there a particular minimum version needed? Or is it a case of compiling find with a special configure switch? – yukondude Oct 01 '08 at 17:07
-
1@yukondude: You're right. The version of find I have locally -- GNU 4.4.0 -- has it, while 4.1.20 that I have on Dreamhost doesn't. The kludge with creating two files should work in either, though. – Arve Oct 02 '08 at 07:45
-
1On some systems (FreeBSD, OS/X...) `-newerBt` will match on the file's _birth_ (creation) time. – Stephane Chazelas Jul 21 '14 at 13:20
-
3Note that the `-newerxt` is available on [FreeBSD](http://svnweb.freebsd.org/base?view=revision&revision=76250) since 2001 (where it was first provided [as a patch](http://markmail.org/thread/mvofenww57bai3vk) in 1998), a few other BSDs and GNU find (since 4.3.3 in 2007), based on HP/UX find, which introduced `-newerXY` (but where Y == t is not supported). – Stephane Chazelas Jul 21 '14 at 14:00
-
Using: find (GNU findutils) 4.4.0, this syntax does not work on SUSE ext3, if it's supposed to list files /w mtime on that date, it returns nothing – niken Oct 14 '15 at 17:04
-
1Note that the exclamation point may need to be escaped (`\!`) if you have Bash history substitution enabled (which is the default). Or you can disable it with `set +H`. – Dennis Williamson Feb 06 '19 at 00:21
-
1Linked tutorial (http://www.virtuelvis.com/2008/10/how-to-use-find-to-search-for-files-created-on-a-specific-date/) is dead – Dawid Moś Jan 31 '21 at 19:24
-
archive.org link of the mentioned tutorial: https://web.archive.org/web/20200216130020/http://virtuelvis.com/2008/10/how-to-use-find-to-search-for-files-created-on-a-specific-date/ – holzkohlengrill Nov 07 '22 at 15:17
Use this command to search for files and folders on /home/
add a time period of time according to your needs:
find /home/ -ctime time_period
Examples of time_period:
More than 30 days ago:
-ctime +30
Less than 30 days ago:
-ctime -30
Exactly 30 days ago:
-ctime 30
-
8The problem is that I want to test for a specific date, not within a time period. – sverrejoh Oct 01 '08 at 15:06
-
1
-
29`ctime` has nothing to do with the _creation time_, it's the inode change time. – Stephane Chazelas Jan 22 '14 at 12:58
It's two steps but I like to do it this way:
First create a file with a particular date/time. In this case, the file is 2008-10-01 at midnight
touch -t 0810010000 /tmp/t
Now we can find all files that are newer or older than the above file (going by file modified date).
You can also use -anewer for accessed and -cnewer file status changed.
find / -newer /tmp/t
find / -not -newer /tmp/t
You could also look at files between certain dates by creating two files with touch
touch -t 0810010000 /tmp/t1
touch -t 0810011000 /tmp/t2
This will find files between the two dates & times
find / -newer /tmp/t1 -and -not -newer /tmp/t2
-
4
-
1IMO, right now this should be the accepted solution. I couldn't get -newermt to run on 2.6.18-348.18.1.el5 kernel, let alone newer kernels. – DarkForce May 20 '15 at 12:29
-
Same here DarkForce, newermt functionality appears to be very very wonky – niken Oct 14 '15 at 17:15
You could do this:
find ./ -type f -ls |grep '10 Sep'
Example:
[root@pbx etc]# find /var/ -type f -ls | grep "Dec 24"
791235 4 -rw-r--r-- 1 root root 29 Dec 24 03:24 /var/lib/prelink/full
798227 288 -rw-r--r-- 1 root root 292323 Dec 24 23:53 /var/log/sa/sar24
797244 320 -rw-r--r-- 1 root root 321300 Dec 24 23:50 /var/log/sa/sa24

- 18,644
- 14
- 87
- 92

- 588
- 3
- 2
-
-
3this might not work on having a few million files in one directory. – Dennis Nolte May 19 '16 at 15:17
-
5
-
https://mywiki.wooledge.org/ParsingLs -- a better approach is probably to print the creation date in machine-readable form, perhaps with `stat` if you don't have `find -printf`. – tripleee Apr 05 '18 at 12:55
-
Regarding "million files" use `find ./ -type f -mtime -60 -ls | grep '10 Sep'` if this date is inside the last 60 days. – mgutt Jan 14 '22 at 08:10
You can't. The -c switch tells you when the permissions were last changed, -a tests the most recent access time, and -m tests the modification time. The filesystem used by most flavors of Linux (ext3) doesn't support a "creation time" record. Sorry!

- 8,229
- 7
- 45
- 59
-
8In fact, it's not just the filesystem type - there is no system interface for obtaining such information, even if the filesystem held it. One of the deficiencies of Unix going back to the earliest days, which is why Unix will never take off. – chrisdowney Jun 16 '11 at 11:41
-
2
@Max: is right about the creation time.
However, if you want to calculate the elapsed days argument for one of the -atime
, -ctime
, -mtime
parameters, you can use the following expression
ELAPSED_DAYS=$(( ( $(date +%s) - $(date -d '2008-09-24' +%s) ) / 60 / 60 / 24 - 1 ))
Replace "2008-09-24" with whatever date you want and ELAPSED_DAYS will be set to the number of days between then and today. (Update: subtract one from the result to align with find
's date rounding.)
So, to find any file modified on September 24th, 2008, the command would be:
find . -type f -mtime $(( ( $(date +%s) - $(date -d '2008-09-24' +%s) ) / 60 / 60 / 24 - 1 ))
This will work if your version of find
doesn't support the -newerXY
predicates mentioned in @Arve:'s answer.

- 24,013
- 13
- 49
- 58
With the -atime, -ctime, and -mtime switches to find, you can get close to what you want to achieve.

- 10,406
- 6
- 33
- 48
cp `ls -ltr | grep 'Jun 14' | perl -wne 's/^.*\s+(\S+)$/$1/; print $1 . "\n";'` /some_destination_dir

- 1
- 1
-
2Why are you copying the files? Besides the command in `\`ls ...\`` works, it does not use the `find` tool. – Yamaneko Nov 08 '12 at 16:47
-
https://unix.stackexchange.com/questions/128985/why-not-parse-ls-and-what-to-do-instead – Danin May 07 '23 at 19:32
I found this scriplet in a script that deletes all files older than 14 days:
CNT=0
for i in $(find -type f -ctime +14); do
((CNT = CNT + 1))
echo -n "." >> $PROGRESS
rm -f $i
done
echo deleted $CNT files, done at $(date "+%H:%M:%S") >> $LOG
I think a little additional "man find" and looking for the -ctime / -atime etc. parameters will help you here.

- 4,402
- 4
- 24
- 20