touch command is used to modify the timestamps of the file. Suppose, you want to modify the time stamp of the file top.txt, use the command as follows:
linux:~ # ls -l top.txt
-rw-r–r– 1 root root 9637 Apr 2 00:20 top.txt
linux:~ #
linux:~ # touch -t 201106062145 top.txt
linux:~ # ls -l top.txt
-rw-r–r– 1 root root 9637 Jun 6 2011 top.txt
linux:~ #
The “-t” option modifies the time stamp of the file and the format is YYYYMMDDHHMM.
If you want to change the modification time of the file to current time, use the touch command with “-m” option as demonstrated below:
linux:~ # ls -l top.txt
-rw-r–r– 1 root root 9637 Jun 6 2011 top.txt
linux:~ #
linux:~ # touch -m top.txt
linux:~ #
linux:~ # ls -l top.txt
-rw-r–r– 1 root root 9637 Apr 2 14:29 top.txt
linux:~ #
The time stamp is changed to current system date and time after touch command is run with ‘-m’ option.