2014-02-11 00:35:16 +00:00
|
|
|
# touch
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
> Change a file access and modification times (atime, mtime).
|
2021-04-01 16:54:26 +01:00
|
|
|
> More information: <https://www.gnu.org/software/coreutils/touch>.
|
2014-02-11 00:35:16 +00:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Create a new empty file(s) or change the times for existing file(s) to current time:
|
2014-02-11 00:35:16 +00:00
|
|
|
|
2021-10-29 18:43:29 +01:00
|
|
|
`touch {{path/to/file}}`
|
2014-02-11 00:35:16 +00:00
|
|
|
|
2016-01-20 11:44:25 +00:00
|
|
|
- Set the times on a file to a specific date and time:
|
2014-02-11 00:35:16 +00:00
|
|
|
|
2021-10-29 18:43:29 +01:00
|
|
|
`touch -t {{YYYYMMDDHHMM.SS}} {{path/to/file}}`
|
|
|
|
|
|
|
|
- Set the time on a file to one hour in the past:
|
|
|
|
|
|
|
|
`touch -d "{{-1 hour}}" {{path/to/file}}`
|
2014-02-11 00:35:16 +00:00
|
|
|
|
2016-01-20 11:44:25 +00:00
|
|
|
- Use the times from a file to set the times on a second file:
|
2014-02-11 00:35:16 +00:00
|
|
|
|
2021-10-29 18:43:29 +01:00
|
|
|
`touch -r {{path/to/file1}} {{path/to/file2}}`
|
2021-05-14 01:40:50 +01:00
|
|
|
|
|
|
|
- Create multiple files:
|
|
|
|
|
2021-10-29 18:43:29 +01:00
|
|
|
`touch {{path/to/file{1,2,3}.txt}}`
|