touch - Updates file access and modification times
touch [-acfm] [-r reference_file|-t time] file...
The following older syntax is now maintained for backward compatibility, but may be withdrawn in future issues: touch [-acfm] [time] file...
Interfaces documented on this reference page conform to industry standards as follows:
touch: XPG4, XPG4-UNIX
Refer to the
reference page for more information
about industry standards and associated tags.
Changes only the access time. Suppresses the creation of the file. [Compaq] Attempts to force the touch in spite of read and write permissions on a file. The -f option is actually a dummy option; it is not used by the touch code, but is recognized by getopt(). Changes only the modification time. Uses the time of the file named by the pathname reference_file instead of the current time. You cannot use -r and -t together. Uses the specified time instead of the current time.
If neither the
option nor the
options are specified,
behaves as if you have specified
The file for which times should be modified, or which should be created.
The touch command updates the access and modification times of each file or directory named to the one specified on the command line or to the current time if you do not specify a time. You can specify the time with -t or by the time of the reference file with the -r option. If you do not specify a time, touch uses the current time. If you specify a file that does not exist, touch creates a file with that name unless you request otherwise with the -c option.
The LC_TIME environment variable, if defined, specifies the order of month and day in the date specification and of hour and minute in the time specification. Otherwise, these orders default to MMdd and hhmm. The format for the time argument is MMddhhmm[yy].
The obsolescent format for the
The obsolescent version may be withdrawn from future versions of the XPG4
and XPG4-UNIX standards. The
options should be used.
The following exit values are returned: Successful completion. [Compaq] The number of files whose times could not be successfully modified (including files that did not exist and were not created).
option is specified, files are suppressed
purposely, an error does not occur and a message is not written to standard
error. The exit status returns zero (0) for success.
To update the access and modification times of a file, enter: touch program.c
The following environment variables affect the execution of
Provides a default value for the internationalization variables
that are unset or null. If
is unset or null, the corresponding value from the default locale is used.
If any of the internationalization variables contain an invalid setting, the
utility behaves as if none of the variables had been defined.
If set to a non-empty string value, overrides the values of
all the other internationalization variables.
Determines the locale for the interpretation of sequences
of bytes of text data as characters (for example, single-byte as opposed to
multibyte characters in arguments).
Determines the locale for the format and contents of diagnostic
messages written to standard error.
[Compaq] This environment variable, if defined, specifies
the order of month and day in the date specification and of hour and minute
in the time specification. Otherwise, these orders default to
hhmm. The format for the
Determines the location of message catalogues for the processing
Determines the time zone to be used for interpreting the
Functions: creat(2), utime(2)