LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 08-14-2006, 04:59 AM   #1
jayukanna
LQ Newbie
 
Registered: Aug 2006
Posts: 3

Rep: Reputation: 0
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
 
Old 08-14-2006, 05:03 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
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.
 
Old 08-14-2006, 06:47 AM   #3
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: Ubuntu, FreeBSD, NetBSD
Posts: 1,449

Rep: Reputation: 47
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.
 
Old 08-21-2006, 12:57 AM   #4
jayukanna
LQ Newbie
 
Registered: Aug 2006
Posts: 3

Original Poster
Rep: Reputation: 0
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.
 
Old 08-21-2006, 02:46 AM   #5
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Only FreeBSD and the UFS2 filesystem support file creation times (that they call "birth time")
 
Old 08-21-2006, 07:08 AM   #6
mkirc
Member
 
Registered: Apr 2006
Location: Vienna-Austria
Distribution: Suse 10.x, Fedora, DSL
Posts: 63

Rep: Reputation: 15
find . -atime +3 -exec ls \;

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
i want to know the command which show the date of creation of file abhi_singh4 Red Hat 6 09-16-2011 12:02 AM
Finding out the creation date for files/folders... darkarcon2015 Linux - Software 1 03-24-2005 05:59 PM
ls -al file creation date blackzone Linux - Newbie 2 08-23-2004 01:31 AM
php read file creation, modified date problem antony_csf Programming 3 08-18-2004 06:46 AM
creation date of file using the 'ls' command robt Linux - Newbie 1 03-27-2003 12:34 AM


All times are GMT -5. The time now is 05:15 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration