helpermethod
helpermethod

Reputation: 62155

Unix - File Creation Date

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?

Upvotes: 1

Views: 5495

Answers (2)

Martin Wickman
Martin Wickman

Reputation: 19905

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.

Upvotes: 6

Dennis Williamson
Dennis Williamson

Reputation: 359985

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

Upvotes: 1

Related Questions