touch(C)


touch -- update access and modification times of a file

Syntax

touch [ -acm ] [ -r ref_file ] [ -t [[CC]YY]MMDDhhmm[.ss] ] file ...

touch [ -acm ] [ MMDDhhmm[yy] ] file ...

Description

touch updates the access and modification times of each file argument. touch uses the current time if none is specified (see date(C)).

touch can set the modification and access times to any specified time when creating a new file. The inode change time, however, is set to the current time and cannot be changed.

touch supports the following options:


-a
Update the access time only. The modification time is not changed unless the -m option is also specified.

-c
Silently prevent touch from creating a file if it does not already exist.

-m
Update the modification time only. The access time is not changed unless the -a option is also specified.

-r
Use the access and modification times of the file ref_file instead of the current time.

-t
Use the specified time instead of the current time. The form of the specified time is [[CC]YY]MMDDhhmm[.ss]:

CC
first two digits of the year (the century minus one) [19-20];

YY
last two digits of the year [00-99]

MM
month [01-12]

DD
day [01-31]

hh
hour [00-23]

mm
minute [00-59]

ss
second [00-61]; the values 60 and 61 are used for leap seconds
If neither -a nor -m is given, touch updates both the access and modification times (equivalent to specifying -am).

Backwards compatibility

If neither -r nor -t is specified, there are two or more arguments, and the first argument is an eight or ten-digit number, touch interprets the number as the access and modification time. Otherwise, touch assumes the argument is a filename to be touched.

The time format is MMDDhhmm[yy]; yy is a year number in the range 69-99 corresponding to 1969-1999. The other components of the time have the same meaning as their -t counterparts

Exit values

touch returns the number of files for which the times could not be successfully modified (including files that did not exist and were not created).

Examples

touch *.c sets the access and modifications times of all the C-source files in the present working directory to the current time. This causes all the target files which depend on these files to be remade if make(CP) is subsequently invoked.

touch andgo sets the access and modification time on the file andgo to the current time, as does touch -am andgo.

touch -a -t 199201010000.00 andgo sets only the access time on andgo to the beginning of 1992.

See also

date(C), utime(S)

Standards conformance

touch is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.

Notices

A version of touch that can handle files greater than 2GB is available in /u95/bin. See touch(1) for more information.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005