Touch


From Linuxconfig.org

Jump to: navigation, search

.. back to the list of Linux Commands

Name

touch - change file timestamps

Synopsis - man page

touch [OPTION]... FILE...

Frequently used options

-a     change only the access time
-m     change only the modification time
-t STAMP 
       use [[CC]YY]MMDDhhmm[.ss] instead of current time

Examples

touch command enables us to change access and modification time for a given files. Also touch command can be use to create files. Lets create file named touchfile.txt:

$ touch touchfile.txt
Image:touch01.gif

To investigate more about this file we can use stat command.

$ stat touchfile.txt
Image:touch02.gif

now we can use touch command to change access and modification time to current time:

$ touch touchfile.txt
Image:touch03.gif

To change only modification time we can use -m option:

$ touch -m touchfile.txt
Image:touch04.gif

Or if we want to change just access time we use -a option

$ touch -a touchfile.txt
Image:touch05.gif

Now lets say that we would like to change access and modification time back to 29 January 2005 13:45.45

$ touch -t 200501291345.45 touchfile.txt
Image:touch06.gif

.. back to the list of Linux Commands

Personal tools
Linux Commands