Monday, November 26, 2012

How to change file creation date?

I had a series of four weekly reports, and I wanted them to show up in ls -l in an ascending series by creation date.

The date on one of the files was "wrong" - it didn't fit into the ascending series.

The first thing to realize is that ls -l is not showing the creation date, but rather the access time. Compare this with modification time.

Anyway, it's very easy to change a file's access time, using touch -t, assuming you own the file:
$ ls -l bubba
-rw-r--r-- 1 smithfarm users 0 Nov 26 18:19 bubba
$ touch -t 201210261819 bubba
$ ls -l bubba
-rw-r--r-- 1 smithfarm users 0 Oct 26 18:19 bubba

For more information on this topic, see this Unix for Dummies Q&A forum post.

No comments:

Post a Comment