Get via App Store Read this post in our app!
How to use ‘find’ to search for files created on a specific date? [closed]
How do I use the UNIX directive find to search for files created on a specific date?
closed as off-topic by Andrew Barber Aug 1 ’13 at Eighteen:25
This question emerges to be off-topic. The users who voted to close gave this specific reason:
- ",Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve instruments used primarily for programming. You may be able to get help on Super User.", &ndash, Andrew Barber
If this question can be reworded to fit the rules in the help center, please edit the question.
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:
To find all files accessed on the 29th of september, 2008:
Or, files which had their permission switched on the same day:
If you don’t switch permissions on the file, ‘c’ would normally correspond to the creation date, tho’.
find location -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
It’s two steps but I like to do it this way:
Very first create a file with a particular date/time. In this case, the file is 2008-10-01 at midnight
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 switched).
You could also look at files inbetween certain dates by creating two files with touch
This will find files inbetween the two dates &, times
You could do this:
You can’t. The -c switch tells you when the permissions were last switched, -a tests the most latest 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!
@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
Substitute “2008-09-24” with whatever date you want and ELAPSED_DAYS will be set to the number of days inbetween 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 directive would be:
This will work if your version of find doesn’t support the -newerXY predicates mentioned in @Arve:’s response.
With the -atime, -ctime, and -mtime switches to find, you can get close to what you want to achieve.
I found this scriplet in a script that deletes all files older than 14 days:
I think a little extra “man find” and looking for the -ctime / -atime etc. parameters will help you here.