TOUCH(1) General Commands Manual TOUCH(1)

touchchange file access and modification times

touch [-acfhm] [-d isotime | -t datetime | -r ref_file] file...

touch changes the date modification and access times on each file it is given.

Change the access time, no changes to modification time unless -m is also given.
Do not create file.
Ignored. coreutils and BusyBox never supported it, OpenBSD removed it in 2005, NetBSD in 2011, FreeBSD in 2012.
isotime
Should be formatted either with a leading @ (at) symbol followed by the Unix timestamp (number of seconds before and after 1970-01-01 00:00:00Z), for example ‘@1698791420’ corresponds to 2023-10-31 23:30:20 UTC

Or as ‘YYYY-MM-DDThh:mm:SS[frac][tz]’, where:

YYYY-MM-DD
Corresponds to %Y-%m-%d of strptime(3).
T
Is either ‘T’ or a space.
[frac]
Is either empty, or fractional seconds starting with either a comma (,) or a period (.).
[tz]
When empty it corresponds to local time. Otherwise it can be an UTC offset in the format ‘[+-]HH:?MM’ or the letter "Z", signifying UTC.

Some examples:

  • 2003-06-02T13:37:42.713Z
  • 1971-01-02T03:04:05.678+0900
Ignored.
Do not follow symlinks.
Change the modification time, no changes to access time unless -a is also given.
datetime
Use the specified datetime instead of the current time, with the form [[CC]YY]MMDDhhmm[.SS] where:
CC
Corresponds to the first 2 digits of the year, aka %C
YY
Corresponds to the last 2 digits of the year, aka %y
MMDDhhmm
Corresponds to month, day, hours, minutes aka %m%d%H%M
.SS
Corresponds to the seconds

For example: ‘200306021337.42

ref_file
Use the corresponding times of the file at ref_file instead of the current time.

The touch utility exits 0 on success, and >0 if an error occurs. Note: Will exit with failure when -c is given but the file doesn't exists.

stat(1), futimens(3), strptime(3)

touch should be compliant with the IEEE Std 1003.1-2024 (“POSIX.1”) specification.

-h and -f are extensions.

Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>

2023-06-03 Linux 6.6.67-gentoo-x86_64