LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   List/compare a directory's files' creation and modification dates (https://www.linuxquestions.org/questions/linux-newbie-8/list-compare-a-directory%27s-files%27-creation-and-modification-dates-593690/)

LittleTrish 10-22-2007 10:56 AM

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

Osiris990 10-22-2007 11:21 AM

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.

bigrigdriver 10-22-2007 02:23 PM

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.

Osiris990 10-22-2007 02:38 PM

Quote:

Originally Posted by bigrigdriver (Post 2932855)
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. =[


All times are GMT -5. The time now is 08:19 PM.