1 min read

Modify the timestamp of files


The “-t” option modifies the time stamp of the file and the format is YYYYMMDDHHMM. The time stamp is changed to current system date and time after touch command is run with ‘-m’ option.as example if we got a file called tcp.php

executing the command

$ stat tcp.php

result

Access: 2022-7-6 21:58:21 
Modify: 2022-7-6 21:58:21

then :

touch -a -m -t 19770707 index.php

will change timestamp to 07/07/1977 to touch a file with specific time :

$ touch -d "1977-07-07 12:12:12" tcp.php

additionally we can copy other file timestamp by using this command:

$ touch a.php -r b.php