touch
can be used to change a file's atime and mtime (but not to change its ctime). -c
is specified) -a | Change only access time | |
-c , --no-create | Don't create any files | |
-d , --date | =STRING | Parse STRING and use it instead of current time |
-f | ignored | |
-h , --no-dereference | Affect each symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink) | |
-m | change only the modification time | |
-r , --reference | =FILE | use file's times instead of current time |
-t | STAMP | Use [[CC]YY]MMDDhhmm[.ss] instead of current time |
--time | =WORD | Change the specified time: WORD is access , atime , or use: equivalent to -a . WORD is modify or mtime: equivalent to -m` |
--help | ||
--version |
-t
can be used to specify a timestamp in [yy]yymmddhhmm[.ss]
format. -t
is combined with -a
to change the access and -m
to change the modification time. touch -m -t 201011121314.15 touched touch -a -t 201211100908.07 touched stat --format="Last access time: %x" touched stat --format="Last modification time: %y" touched
-d
can be used to specify an arbitrary (possibly relative) date with which the file is created or touched. touch -d "10 days ago" ...
touch -r another-file file-to-touch ...
truncate
touch
in PowerShell with new-item
(to create a new file) or
set-itemProperty
(to modify a file's last write time). File::Touch
set-content empty.txt $null
. This command creates a zero byte file named empty.txt
. touch.ps1
is a PowerShell Scripts that creates a file if it does not exist or updates an existing file's timestamps.