Forrest logo
back to the touch tool

touch:tldr:ad572

touch: Set the file [t]ime to a specific value and don't [c]reate file if it doesn't exist.
$ touch -c -t ${YYYYMMDDHHMM-SS} ${filename1 filename2 ---}
try on your machine

The command "touch -c -t ${YYYYMMDDHHMM-SS} ${filename1 filename2 ---}" is used to update the timestamp of specified files to a specific date and time.

Explanation of each part of the command:

  • "touch" is a command used to create empty files or update the timestamps of existing files.
  • "-c" flag tells the touch command to not create any new files. It is used in conjunction with the "-t" flag.
  • "-t" flag is followed by the desired timestamp format ${YYYYMMDDHHMM-SS}. It specifies the date and time in the format year (4 digits), month (2 digits), day (2 digits), hour (24-hour format, 2 digits), minute (2 digits), and second (2 digits). The timestamp can be customized by replacing the variables inside the curly braces (${YYYYMMDDHHMM-SS}) with the desired values.
  • "${filename1 filename2 ---}" represents the list of files for which the timestamp needs to be updated. Multiple filenames can be included, separated by spaces.

To use this command, you would replace "${YYYYMMDDHHMM-SS}" with the desired date and time, and "${filename1 filename2 ---}" with the actual filenames you want to update. For example, if you want to update the timestamp of a file named "example.txt" to December 25th, 2020, 10:30 AM, you would use the following command:

touch -c -t 202012251030.00 example.txt

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the touch tool