TOUCH(1) | General Commands Manual | TOUCH(1) |
touch
— change
file access and modification times
touch |
[-A [-][[hh]mm]SS]
[-achm ] [-r
file] [-t
[[CC]YY]MMDDhhmm[.SS]] [-d
YYYY-MM-DDThh:mm:SS[.frac][tz]] file
... |
The touch
utility sets the modification
and access times of files. If any file does not exist, it is created with
default permissions.
By default, touch
changes both
modification and access times. The -a
and
-m
flags may be used to select the access time or
the modification time individually. Selecting both is equivalent to the
default. By default, the timestamps are set to the current time. The
-d
and -t
flags explicitly
specify a different time, and the -r
flag specifies
to set the times those of the specified file. The -A
flag adjusts the values by a specified amount.
The following options are available:
-A
The argument is of the form “[-][[hh]mm]SS” where each pair of letters represents the following:
The -A
flag implies the
-c
flag: if any file specified does not exist,
it will be silently ignored.
-a
-m
flag is also
specified.-c
touch
utility does not treat this as an error. No
error messages are displayed and the exit value is not affected.-d
-t
time.T
or a space is the time
designator.Z
indicating the time is in
UTC. Otherwise, the time is assumed to be in local time. Local time is
affected by the value of the TZ
environment
variable.-h
-h
implies -c
and thus
will not create any new files.-m
-a
flag is also
specified.-r
-t
If the “CC” and “YY” letter pairs are not specified, the values default to the current year. If the “SS” letter pair is not specified, the value defaults to 0.
The touch
utility exits 0 on
success, and >0 if an error occurs.
The obsolescent form of touch
, where a
time format is specified as the first argument, is supported. When no
-r
or -t
option is
specified, there are at least two arguments, and the first argument is a
string of digits either eight or ten characters in length, the first
argument is interpreted as a time specification of the form
“MMDDhhmm[YY]”.
The “MM”, “DD”, “hh” and
“mm” letter pairs are treated as their counterparts specified
to the -t
option. If the “YY” letter
pair is in the range 39 to 99, the year is set to 1939 to 1999, otherwise,
the year is set in the 21st century.
The touch
utility is expected to be a
superset of the IEEE Std 1003.2
(“POSIX.2”) specification.
A touch
utility appeared in
Version 7 AT&T UNIX.
June 1, 2018 | macOS 14.6 |