LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-22-2007, 11:56 AM   #1
LittleTrish
LQ Newbie
 
Registered: Oct 2007
Posts: 1

Rep: Reputation: 0
List/compare a directory's files' creation and modification dates


I'm sure there is an easy way to do this, but I just can't seem to figure it out. I am trying to find files that have been updated since their original creation date. It would be great to issue a command that will give me this information. I would also be perfectly happy to have some sort of 'ls' command that lists both the creation and modification dates so I can manually check the output for ones that have been updated. Of course the first option is ideal, but right now I'm just looking for any solution.

Is there a command out there that will do this for me? Right now I'm only seeing how to list the modification dates.

Thanks so much!
Trish
 
Old 10-22-2007, 12:21 PM   #2
Osiris990
Member
 
Registered: Oct 2005
Location: Dallas, TX
Distribution: Slackware 12
Posts: 49

Rep: Reputation: 15
Try playing around with
Code:
ls -alc
. It seems to be working a little weird on my system, as it's displaying creation time when I do -al and modification time when I do -alc, but *shrug*. According to the ls man pages, you use the --time=TIME switch to modify what the time column (the column that shows the modification time). Just mess around with it a bit, maybe create a bash script that throws in a few greps along with those ls's and you should be good.
 
Old 10-22-2007, 03:23 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,796

Rep: Reputation: 323Reputation: 323Reputation: 323Reputation: 323
Unfortunately, the system does not store information about creation time. You can have ctime (change time), mtime (modification time) and atime (access time).

If the file's properties or permissions are changed, ctime changes. If the file is accessed, atime changes. If the file is modified, both atime and mtime change.

For new files and files that have not been modified or changed since creation, ctime equals creation time. But, as soon as file properties are changed, and a file is modified, all information about creation time is lost.

You only hope is that file properties have not been changed since creation. In that case, access and modification times differ from ctime (with ctime having the earlier date and time).

To see all three times, use stat, as in 'stat <filename>'. With stat, and a bit of awk magic (since the stat output is arranged in horizontal records with distinct fields), you could write a script to select files based on differences between ctime and atime or mtime. However, it won't be exact, for reasons stated above.
 
Old 10-22-2007, 03:38 PM   #4
Osiris990
Member
 
Registered: Oct 2005
Location: Dallas, TX
Distribution: Slackware 12
Posts: 49

Rep: Reputation: 15
Quote:
Originally Posted by bigrigdriver View Post
Unfortunately, the system does not store information about creation time. You can have ctime (change time), mtime (modification time) and atime (access time).

If the file's properties or permissions are changed, ctime changes. If the file is accessed, atime changes. If the file is modified, both atime and mtime change.

For new files and files that have not been modified or changed since creation, ctime equals creation time. But, as soon as file properties are changed, and a file is modified, all information about creation time is lost.

You only hope is that file properties have not been changed since creation. In that case, access and modification times differ from ctime (with ctime having the earlier date and time).

To see all three times, use stat, as in 'stat <filename>'. With stat, and a bit of awk magic (since the stat output is arranged in horizontal records with distinct fields), you could write a script to select files based on differences between ctime and atime or mtime. However, it won't be exact, for reasons stated above.
Ah, I assumed ctime was creation time since it did not say what it was exactly in the man pages. My mistake. =[
 
  


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
samba doesn't change modification dates? Rotwang Linux - Networking 2 10-03-2007 11:24 AM
Checking directories modification dates crofty13 Linux - Software 1 06-25-2007 11:50 AM
Compare Dates?? sachinh Linux - General 12 05-22-2007 05:17 AM
Samba missing files / and directory's estaban Linux - Software 1 06-14-2006 04:38 PM
how to view the detail infomation of a directory's files? arcow Linux - Software 2 02-10-2006 02:47 AM


All times are GMT -5. The time now is 12:35 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