LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   File Creation Date in linux (https://www.linuxquestions.org/questions/general-10/file-creation-date-in-linux-473684/)

jayukanna 08-14-2006 04:59 AM

File Creation Date in linux
 
This is a very simple problem. but i was not able to find solution.

Lets say a folder has 5 Files. In this 2 files were created 3 days and other files are older than 5 days.
How do we find, using linux shell script the name of files which have been created in the past 3 days (with respect to the current date).

For example, in the above example, if I excute the shell script today, 2 files names should be displayed.

If I execute the same shell script after 10 days, none of the files names should be displayed.

Can someone please help me?

Thanks,
Jayukanna

druuna 08-14-2006 05:03 AM

Hi,

Take a look at find, especially the -mtime option:

find -mtime -3

-3 younger then 3 days, +3 older then 3 days.

Hope this helps.

frob23 08-14-2006 06:47 AM

The mtime option sorts by the last time a file was modified. Assuming the files are created and then left alone, it would work in this case. If the files are being edited after creation, we're up a creek without a paddle. There is no standard way to store creation date for a file. If it's absolutely important that you know the date (albeit not the time) a file was created, you may want to run a script from cron, on a daily basis, to manually discover new files and record their appearance. It still won't be perfect because a file could be removed and later replaced by one with the same name and it would appear older than it actually was by that method.

jayukanna 08-21-2006 12:57 AM

thanks
 
Thanks for all your time and reply.
From all your comments it would mean that, we can find the file modified date only and not file creation date.

primo 08-21-2006 02:46 AM

Only FreeBSD and the UFS2 filesystem support file creation times (that they call "birth time") :(

mkirc 08-21-2006 07:08 AM

find . -atime +3 -exec ls \;

atime..last access
mtime..last modify
ctime..last status change


All times are GMT -5. The time now is 03:45 AM.