views:

58

answers:

2

For an assignment I need to determine the creation time of a random file. As far as I know, Unix does not store the creation time (in contrast to *-BSD). I think I've read somewhere that you should ask for the modification time instead but I don't know where and asking Google doesn't give me a non-ambigious answser either.

Any ideas?

+1  A: 

Try stat. It will give you all the times associated with a file.

stat filename

To get just the modification date and time:

stat --format=%y filename

Or in seconds since the Epoch:

stat --format=%Y filename
Dennis Williamson
+1 Thanks but what I'll need to know is, if someone speaks of creation time in a Unix (Non-BSD) environment, is modification time what is meant.
Helper Method
+4  A: 

You cannot get the creation time of files in this context. That makes the assignment easy enough: it reasonably cannot be completed.

If someone is talking about creation time in Unix, they are confused. Modification time is completely different from creation time (obviously).

For the record, there are exactly three timestamps in Unix files: ctime, atime and mtime.

Martin Wickman