2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 .\" Portions Copyright (c) 2009, Sun Mricrosystems, Inc. All Rights Reserved
47 .TH TOUCH 1 "Sep 9, 2009"
49 touch, settime \- change file access and modification times
53 \fBtouch\fR [\fB-acm\fR] [\fB-r\fR \fIref_file\fR | \fB-t\fR \fItime\fR | \fB-d\fR \fIdate_time\fR] \fIfile\fR...
58 \fBtouch\fR [\fB-acm\fR] [\fItime_spec\fR] \fIfile\fR...
63 \fBsettime\fR [\fB-f\fR \fIref_file\fR] [\fItime_spec\fR] \fIfile\fR...
69 The \fBtouch\fR utility sets the access and modification times of each file.
70 The \fIfile\fR operand is created if it does not already exist.
73 The time used can be specified by \fB-t\fR \fItime\fR, by \fB-d\fR
74 \fIdate_time\fR, by the corresponding time fields of the file referenced by
75 \fB-r\fR \fIref_file\fR, or by the \fItime_spec\fR operand. If none of these
76 are specified, \fBtouch\fR uses the current time.
79 If neither the \fB-a\fR nor \fB-m\fR options are specified, \fBtouch\fR updates
80 both the modification and access times.
83 A user with write access to a file, but who is not the owner of the file or a
84 super-user, can change the modification and access times of that file only to
85 the current time. Attempts to set a specific time with \fBtouch\fR results in
89 The \fBsettime\fR utility is equivalent to \fBtouch\fR \fB-c\fR
90 [\fItime_spec\fR] \fIfile\fR.
94 The following options are supported in the \fBtouch\fR and \fBsettime\fR
99 The following options are supported for the \fBtouch\fR utility:
107 Changes the access time of \fIfile\fR. Does not change the modification time
108 unless \fB-m\fR is also specified.
118 Does not create a specified \fIfile\fR if it does not exist. Does not write any
119 diagnostic messages concerning this condition.
125 \fB\fB-d\fR \fIdate_time\fR\fR
129 Uses the specified date_time instead of the current time. The option-argument
130 must be a string of the form:
134 \fIYYYY\fR-\fIMM\fR-\fIDDThh\fR:\fImm\fR:\fISS\fR[.\fIfrac\fR][\fItz\fR]
143 \fIYYYY\fR-\fIMM\fR-\fIDDThh\fR:\fImm\fR:\fISS\fR[,\fIfrac\fR][\fItz\fR]
153 \fIYYYY\fR is at least four decimal digits giving the year
159 \fIMM\fR, \fIDD\fR, \fIhh\fR, \fImm\fR, and \fISS\fR are as with \fB-t\fR
166 \fIT\fR is either the letter \fBT\fR or a single SPACE character
172 [\fI\&.frac\fR] and [\fI,frac\fR] are either empty, or a period (\fB\&.\fR) or
173 a comma (\fB,\fR) respectively, followed by one or more decimal digits,
174 specifying a fractional second
180 [\fItz\fR] is either empty, signifying local time, or the letter \fBZ\fR,
181 signifying UTC. If [\fItz\fR] is empty, the resulting time is affected by the
182 value of the \fBTZ\fR environment variable
193 Changes the modification time of \fIfile\fR. Does not change the access time
194 unless \fB-a\fR is also specified.
200 \fB\fB-r\fR \fIref_file\fR\fR
204 Uses the corresponding times of the file named by \fIref_file\fR instead of the
211 \fB\fB-t\fR \fItime\fR\fR
215 Uses the specified \fItime\fR instead of the current time. \fItime\fR is a
216 decimal number of the form:
220 [[\fICC\fR]\fIYY\fR]\fIMMDDhhmm\fR[\fI\&.SS\fR]
225 where each two digits represent the following:
233 The month of the year [01-12].
243 The day of the month [01-31].
253 The hour of the day [00-23].
263 The minute of the hour [00-59].
273 The first two digits of the year.
283 The second two digits of the year.
293 The second of the minute [00-61].
296 Both \fICC\fR and \fIYY\fR are optional. If neither is given, the current year
297 is assumed. If \fIYY\fR is specified, but \fICC\fR is not, \fICC\fR is derived
306 If YY is: CC becomes:
313 The resulting time is affected by the value of the \fBTZ\fR environment
314 variable. If the resulting time value precedes the Epoch, \fBtouch\fR exits
315 immediately with an error status. The range of valid times is the Epoch to
318 The range for \fISS\fR is [00-61] rather than [00-59] because of leap seconds.
319 If \fISS\fR is 60 or 61, and the resulting time, as affected by the \fBTZ\fR
320 environment variable, does not refer to a leap second, the resulting time is
321 one or two seconds after a time where \fISS\fR is 59. If \fISS\fR is not given,
322 it is assumed to be 0.
328 The following option is supported for the \fBsettime\fR utility:
332 \fB\fB-f\fR \fIref_file\fR\fR
336 Uses the corresponding times of the file named by \fIref_file\fR instead of the
343 The following operands are supported for the \fBtouch\fR and \fBsettime\fR
352 A path name of a file whose times are to be modified.
358 \fB\fItime_spec\fR\fR
362 Uses the specified \fItime_spec\fR instead of the current time. This operand is
363 a decimal number of the form:
367 \fIMMDDhhmm\fR[\fIYY\fR]
372 where each two digits represent the following:
380 The month of the year [01-12].
390 The day of the month [01-31].
400 The hour of the day [00-23].
410 The minute of the hour [00-59].
420 The second two digits of the year.
422 \fIYY\fR is optional. If it is omitted, the current year is assumed. If
423 \fIYY\fR is specified, the year is derived as follows:
433 YY Corresponding Year
439 If no \fB-d\fR, \fB-r\fR, or \fB-t\fRoption is specified, at least two operands
440 are specified, and the first operand is an eight- or ten-digit decimal integer,
441 the first operand is assumed to be a \fItime_spec\fR operand. Otherwise, the
442 first operand is assumed to be a \fIfile\fR operand.
445 .SH ENVIRONMENT VARIABLES
448 See \fBenviron\fR(5) for descriptions of the following environment variables
449 that affect the execution of \fBtouch\fR: \fBLANG\fR, \fBLC_ALL\fR, \fBLANG\fR,
450 \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
458 Determine the timezone to be used for interpreting the \fItime\fR or
459 \fIdate_time\fR option-argument or the \fItime_spec\fR operand.
465 The following exit values are returned:
473 The \fBtouch\fR utility executed successfully and all requested changes were
484 An error occurred. The \fBtouch\fR utility returned the number of files for
485 which the times could not be successfully modified.
491 See \fBattributes\fR(5) for descriptions of the following attributes:
499 ATTRIBUTE TYPE ATTRIBUTE VALUE
503 Interface Stability Committed
505 Standard See \fBstandards\fR(5).
511 \fBfutimens\fR(2), \fBstat\fR(2), \fBattributes\fR(5), \fBenviron\fR(5),
516 Users familiar with the BSD environment find that for the \fBtouch\fR utility,
517 the \fB-f\fR option is accepted but ignored. The \fB-f\fR option is unnecessary
518 because \fBtouch\fR succeeds for all files owned by the user regardless of the
519 permissions on the files.