Linux and Unix settime and touch
Quick links
About settime and touch
Syntax
Examples
Related commands
Linux and Unix main page
Change file access and modification time.
touch [-a] [-c] [-m] [-r ref_file | -t time ] file
settime [ -f ref_file ] file
| -a | Change the access time of file. Do not change the modification time unless -m is also specified. |
| -c | Do not create a specified file if it does not exist. Do not write any diagnostic messages concerning this condition. |
| -m | Change the modification time of file. Do not change the access time unless -a is also specified. |
| -r ref_file | Use the corresponding times of the file named by ref_file instead of the current time. |
| -t time | Use the specified time instead of the current time. time will be a decimal number of the form: [[CC]YY]MMDDhhmm [.SS] MM - The month of the year [01-12]. |
| -f ref_file | Use the corresponding times of the file named by ref_file instead of the current time. |
| file | A path name of a file whose times are to be modified. |
settime myfile.txt
Sets the file myfile.txt as the current time / date.
touch newfile.txt
Creates a file known as "newfile.txt", if the file does not already exist. If the file already exists the accessed / modification time is updated for the file newfile.txt
