How do I use the UNIX command find to search for files created on a specific date?
Join Stack Overflow to learn, share knowledge, and build your career.
closed as off-topic by Andrew Barber Aug 1 '13 at 18:25This question appears to be off-topic. The users who voted to close gave this specific reason:
|
|||||||||||||||||||||
|
|||||||||||||||||||||
|
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 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 changed on the same day:
If you don't change permissions on the file, 'c' would normally correspond to the creation date, though. |
|||||||||||||||||||||
|
|
Examples of time_period:
|
|||||||||||||
|
|
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
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).
You could also look at files between certain dates by creating two files with touch
This will find files between the two dates & times
|
||||
|
You could do this:
Example:
|
|||||||||||||
|
|
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! |
|||||
|
|
@Max: is right about the creation time. However, if you want to calculate the elapsed days argument for one of the
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 So, to find any file modified on September 24th, 2008, the command would be:
This will work if your version of |
||||
|
|
|
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 additional "man find" and looking for the -ctime / -atime etc. parameters will help you here. |
|||
|
|