TOUCH(1) User Commands TOUCH(1)

touch - update file access and modification times

touch [-amc] [MMDDhhmm[YY]] file ...
touch [-amc] [-r ref_file|-t time] file ...

The touch utility changes the access and modification times of files. It creates a file if it does not already exist. If none of the arguments specify the time to set, the current time is used.

If neither the -r nor the -t option is used to specify a time value and the first non-option argument begins with a digit, and it consists of exactly eight or ten digits with /usr/5bin/posix/touch and /usr/5bin/posix2001/touch, the times of the files are set to the given time.

The meaning of fields in time specifications is as follows:

CC The first two digits of the year.
YY The second two digits of the year.
MM The month of the year (01-12).
DD The day of the month (01-31).
hh The hour of the day (00-23).
mm The minute of the hour (00-59).
SS The second of the minute (00-61).

Unless YY is present, the current year is used. If YY is given without CC, the century is 19 if YY is in the range of 69–99, or 20 for YY values of 00–68.

The following options are accepted:

Change the access time, but not the modification time unless -m is also present.
If a file does not exist, it is not created. No diagnostic message is printed; for /usr/5bin/touch and /usr/5bin/s42/touch, the exit status is incremented. The exit status is not affected for /usr/5bin/posix/touch and /usr/5bin/posix2001/touch.
Change the access time, but not the modification time unless -a is also present.

The following options have been introduced by POSIX.2:

The corresponding time of the specified file is used instead of the current time.
Instead of the current time, the time specified as
[[CC]YY]MMDDhhmm[.SS]

is used.

The exit status is the number of files that were not successfully processed.

date(1), utime(2)

2/10/05 Heirloom Toolchest