Unix/Linux: Changing the date of a file


SYNTAX:  touch -t [[CC]YY]MMDDhhmm[.ss] file

# ls -l myfile.txt
-rw-r--r-- 1 root root 3735707 Feb  8 05:56 myfile.txt

# stat myfile.txt
  File: `myfile.txt'
  Size: 3735707       Blocks: 7304       IO Block: 4096   regular file
Device: 801h/2049d    Inode: 13895185    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-02-08 05:56:14.977494275 -0500
Modify: 2013-02-08 05:56:23.572695178 -0500
Change: 2013-02-08 05:56:23.572695178 -0500
 Birth: -



Change the date to 12/25/1999 at 10:30 AM:

# touch -t 199912251030 myfile.txt

# ls -l myfile.txt
-rw-r--r-- 1 root root 3735707 Dec 25  1999 myfile.txt

# stat myfile.txt
  File: `myfile.txt'
  Size: 3735707       Blocks: 7304       IO Block: 4096   regular file
Device: 801h/2049d    Inode: 13895185    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 1999-12-25 10:30:00.000000000 -0500
Modify: 1999-12-25 10:30:00.000000000 -0500
Change: 2013-02-08 05:57:33.682176907 -0500
 Birth: -