touch changes the access and/or modification timestamps of each
specified
file. These timestamps are changed to the current time, unless
the -r option is specified, in which case they are changed
to the corresponding timestamps of the file
ref_file, or the -t option is specified, in which case they are changed
to the specified
time. Both times are changed when neither or both of the -a and -m
options are given. Only the access or only the modification time
is changed when one of the options -a and -m is given.
If the file did not exist yet, it is created (as an empty file
with mode 0666, modified by the umask), unless the -c option is given.
Use the corresponding timestamp of
ref_file as the new value for the changed timestamp(s).
-t time
Use the specified time as the new value for the changed timestamp(s).
The argument is a decimal number of the form
[[CC]YY]MMDDhhmm[.SS]
with the obvious meaning. If CC is not specified, the year CCYY
is taken to be in the range 1969-2068.
If SS is not specified, it is taken to be 0. It may be specified
in the range 0-61 so that it is possible to refer to leap seconds.
The resulting time is taken as a time for the time zone specified by
the environment variable TZ. It is an error if the resulting time
precedes 1 January 1970.
The second form of invocation has the disadvantage that there is
some ambiguity as to whether
ugly_time is a time or a file argument. It is taken to be a time when
no -r or -t option is present, there are at least two arguments,
and the first argument is an eight- or ten-digit decimal integer.
The format of
ugly_time is MMDDhhmm[yy], where an yy in the range 69-99 denotes a year
in the range 1969-1999, and an unspecified yy denotes the current year.
This form is obsolete.
If the first
file would be a valid argument to the
-t option and no timestamp is given with any of the
-d,
-r or
-t options and the -- argument is not given, that argument is
interpreted as the time for the other files instead of as a filename.
If changing both the access and modification times to the current
time,
touch can change the timestamps for files that the user running it does
not own but has write permission for. Otherwise, the user must
own the files.
Use
time instead of the current time. It can contain month names,
time zones, am and pm, etc.
-f
Ignored; for compatibility with BSD versions of
touch(1).
-m, --time=mtime, --time=modify
Change the modification time only.
-r file, --reference=file
Use the times of the reference
file instead of the current time.
-t decimtime
Here
decimtime has the format MMDDhhmm[[CC]YY][.ss]
Use the argument (months, days, hours, minutes, optional century
and years, optional seconds) instead of the current time.
Note that this format violates the POSIX specification.
The command touch foo will create the file foo
if it didnt exist, and change the time of last modification to now.
It is often used to guide the actions of
make.