HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)

t
touch(1) touch(1)
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:
A time is specified,
Only the access time of the file is being updated, or
Only the modification time of the file is being updated.
In addition,
touch succeeds when invoked by a user with write permission on the file if both of the follow-
ing are true:
No time is specified, and
Both the access time and modification time of the file are being updated.
EXTERNAL INFLUENCES
Environment Variables
TZ If the time is specified via the -t option, TZ is used to interpret the time for the specified time zone.
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 internationaliza-
tion variables are set to "C". See environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
RETURN VALUE
touch returns zero if all le_name arguments were successfully changed.
touch returns non-zero and prints out a diagnostic message if an invalid time or a time earlier than the
Epoch was specified with the -t option, or if the -r and -t options were both specified, or if one or more
of the file_name arguments could not be accessed.
EXAMPLES
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
DEPENDENCIES
NFS:
An attempt to touch a file owned by the super-user on a remote server might fail, even if the invoking user
has write permission on the file.
SEE ALSO
date(1), utime(2).
HP-UX 11i Version 1: September 2005 2 Hewlett-Packard Company Section 1985