Table of Contents

Name

touch - change file access and modification times

Synopsis

touch [-acm][ -r ref_file| -t time] file...

Description

The touch utility shall change the modification times, access times, or both of files. The modification time shall be equivalent to the value of the st_mtime member of the stat structure for a file, as described in the System Interfaces volume of IEEE Std 1003.1-2001; the access time shall be equivalent to the value of st_atime.

The time used can be specified by the -t time option-argument, the corresponding time fields of the file referenced by the -r ref_file option-argument, or the date_time operand, as specified in the following sections. If none of these are specified, touch shall use the current time (the value returned by the equivalent of the time() function defined in the System Interfaces volume of IEEE Std 1003.1-2001).

For each file operand, touch shall perform actions equivalent to the following functions defined in the System Interfaces volume of IEEE Std 1003.1-2001:

If file does not exist, a creat() function call is made with the file operand used as the path argument and the value of the bitwise-inclusive OR of S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, and S_IWOTH used as the mode argument.

The utime() function is called with the following arguments: <ol type="a">

The file operand is used as the path argument.

The utimbuf structure members actime and modtime are determined as described in the OPTIONS section.

Options

The touch utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.

The following options shall be supported:

-a
Change the access time of file. Do not change the modification time unless -m is also specified.
-c
Do not create a specified file if it does not exist. Do not write any diagnostic messages concerning this condition.
-m
Change the modification time of file. Do not change the access time unless -a is also specified.
-r ref_file
Use the corresponding time of the file named by the pathname ref_file instead of the current time.
-t time
Use the specified time instead of the current time. The option-argument shall be a decimal number of the form:


[[CC]YY]MMDDhhmm[.SS]

where each two digits represents the following:

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].
CC
The first two digits of the year (the century).
YY
The second two digits of the year.
SS
The second of the minute [00,60].

Both CC and YY shall be optional. If neither is given, the current year shall be assumed. If YY is specified, but CC is not, CC shall be derived as follows:

Note:It is expected that in a future version of IEEE Std 1003.1-2001the default century inferred from a 2-digit year willOperands

Stdin

Input Files

Environment Variables

Asynchronous Events

Stdout

Stderr

Output Files

Extended Description

Exit Status

Consequences of Errors

Application Usage



Examples

Rationale

Future Directions

See Also

Copyright


Table of Contents