|HP-UX Reference > T
touch(1)HP-UX 11i Version 3: February 2007
touch — update access, modification, and/or change times of file
touch updates the access, modification, and last-change times of each argument. The file name is created if it does not exist. If no time is specified (see date(1)) the current time is used.
The -r and -t options are mutually exclusive.
The following options are available:
The syntax shown by the second SYNOPSIS line is recognized when neither the -r option, the -t option, nor the -- option delimiter is specified, and the first operand consists of all decimal digits. This operand is interpreted as the time argument instead of as a file name. However, in this case, time_str is assumed to be of the form:
This is for backward compatibility. The -t form given above is recommended for future portability. The -- option delimiter can be used before the first file_name if there is a possibility that file_name consists of all digits, in order to ensure that the first syntax is used.
touch succeeds only when invoked by the owner of the file if any of the following are true:
In addition, touch succeeds when invoked by a user with write permission on the file if both of the following are true:
LC_MESSAGES determines the language in which messages are displayed.
If LC_MESSAGES is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG.
If any internationalization variable contains an invalid setting, touch behaves as if all internationalization variables are set to "C". See environ(5).
touch returns the following values:
The following command sets the modification and access times of the file named "bastille" to midnight, July 14, 1989, creating the file if it does not already exist.
touch -t 8907140000 bastille
The following command does the same thing using the backward-compatible syntax:
touch 0714000089 bastille
The following command sets the time of the two files named "0714000089" and "bastille" to the current time, creating them if they do not exist:
touch -- 0714000089 bastille
To create a zero-length file, use any of the following:
touch file cat /dev/null >file cp /dev/null file