The touch -t option is similar to touch -d option, but instead of passing any valid timestamp format like in -d option, -t option only accepts timestamp in [[CC]YY]MMDDhhmm[.ss] format.
Example:
Get the current system time
1 2 |
## Get current timestamp date +"%b %d %T" ## returns Feb 02 18:55:54 |
Create a new empty file
1 2 |
## Create a new empty file touch myfile |
Get the new file creation time
1 2 |
## list all available files ls -l ## -rw-r--r-- 1 debjeet debjeet 0 Feb 2 18:56 myfile |
touch -t option example
1 2 |
## touch -t option touch -d '1903032020' myfile |
Get the file creation time
1 2 3 4 |
## list all available files ls -l ## -rw-r--r-- 1 debjeet debjeet 0 Jan 26 22:30 myfile rm my* |
Observe, the timestamp of myfile changed to “Jan 26 22:30”