Linux/Unix: How to manipulate or change the last modified/accessed time of a file using touch command?
Assume there’s a file @ /home/user/testmsg.txt
If you want to change the file timestamp to 09/20/2011 08:30 using touch command, here’s how you can do it:
# Only change the last accessed time touch -t -a 20110920083000 /home/user/testmsg.txt # Only change the last modified time touch -t -m 20110920083000 /home/user/testmsg.txt # Change both the times - modified and accessed times touch -t 20110920083000 /home/user/testmsg.txt
From Wikipedia,
touch is a standard Unix program used to change a file‘s access and modification timestamps. It is also used to create a new empty file.
Related articles
- Some examples of grep command in unix (javarevisited.wordpress.com)
- Commands to Compare Files in Linux (brighthub.com)
- Learning Unix (tirania.org)
About this entry
You’re currently reading “Linux/Unix: How to manipulate or change the last modified/accessed time of a file using touch command?,” an entry on Singaram's Tech Musings
- Published:
- September 20, 2011 / 12:34 PM
- Category:
- Coding tips, Linux
- Tags:
- Linux, touch command, Unix

1 Comment
Jump to comment form | comment rss [?] | trackback uri [?]