1TOUCH(1P)                  POSIX Programmer's Manual                 TOUCH(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       touch - change file access and modification times
13

SYNOPSIS

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

DESCRIPTION

18       The touch utility shall change the modification times, access times, or
19       both  of  files. The modification time shall be equivalent to the value
20       of the st_mtime member of the stat structure for a file,  as  described
21       in  the  System  Interfaces  volume of IEEE Std 1003.1-2001; the access
22       time shall be equivalent to the value of st_atime.
23
24       The time used can be specified by the -t time option-argument, the cor‐
25       responding  time  fields  of  the  file  referenced  by the -r ref_file
26       option-argument, or the date_time operand, as specified in the  follow‐
27       ing  sections. If none of these are specified, touch shall use the cur‐
28       rent time (the value returned by the equivalent of the time()  function
29       defined in the System Interfaces volume of IEEE Std 1003.1-2001).
30
31       For  each  file  operand, touch shall perform actions equivalent to the
32       following  functions  defined  in  the  System  Interfaces  volume   of
33       IEEE Std 1003.1-2001:
34
35        1. If  file  does  not exist, a creat() function call is made with the
36           file operand used as the path argument and the value  of  the  bit‐
37           wise-inclusive  OR  of S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH,
38           and S_IWOTH used as the mode argument.
39
40        2. The utime() function is called with the following arguments:
41
42            a. The file operand is used as the path argument.
43
44            b. The utimbuf structure members actime and modtime are determined
45               as described in the OPTIONS section.
46

OPTIONS

48       The  touch  utility  shall  conform  to  the Base Definitions volume of
49       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
50
51       The following options shall be supported:
52
53       -a     Change the access time of file. Do not change  the  modification
54              time unless -m is also specified.
55
56       -c     Do  not  create  a  specified  file if it does not exist. Do not
57              write any diagnostic messages concerning this condition.
58
59       -m     Change the modification time of file. Do not change  the  access
60              time unless -a is also specified.
61
62       -r  ref_file
63              Use  the  corresponding  time  of the file named by the pathname
64              ref_file instead of the current time.
65
66       -t  time
67              Use the specified time instead of the current time. The  option-
68              argument shall be a decimal number of the form:
69
70
71              [[CC]YY]MMDDhhmm[.SS]
72
73       where each two digits represents the following:
74
75       MM
76              The month of the year [01,12].
77
78       DD
79              The day of the month [01,31].
80
81       hh
82              The hour of the day [00,23].
83
84       mm
85              The minute of the hour [00,59].
86
87       CC
88              The first two digits of the year (the century).
89
90       YY
91              The second two digits of the year.
92
93       SS
94              The second of the minute [00,60].
95
96
97       Both CC and YY shall be optional. If neither is given, the current year
98       shall be assumed. If YY is specified,  but  CC  is  not,  CC  shall  be
99       derived as follows:
100
101                               If YY is:   CC becomes:
102                               [69,99]     19
103                               [00,68]     20
104
105       Note:
106              It  is expected that in a future version of IEEE Std 1003.1-2001
107              the default century inferred from a 2-digit  year  will  change.
108              (This  would  apply  to all commands accepting a 2-digit year as
109              input.)
110
111
112       The resulting time shall be affected by the value of the TZ environment
113       variable.  If  the resulting time value precedes the Epoch, touch shall
114       exit immediately with an error status.  The range of valid  times  past
115       the  Epoch  is  implementation-defined, but it shall extend to at least
116       the time 0 hours, 0 minutes, 0 seconds, January  1,  2038,  Coordinated
117       Universal Time. Some implementations may not be able to represent dates
118       beyond January 18, 2038, because they use signed int as a time holder.
119
120       The range for SS is [00,60] rather than [00,59] because  of  leap  sec‐
121       onds.  If SS is 60, and the resulting time, as affected by the TZ envi‐
122       ronment variable, does not refer to a leap second, the  resulting  time
123       shall  be  one second after a time where SS is 59. If SS is not given a
124       value, it is assumed to be zero.
125
126
127       If neither the -a nor -m options were specified, touch shall behave  as
128       if both the -a and -m options were specified.
129

OPERANDS

131       The following operands shall be supported:
132
133       file   A pathname of a file whose times shall be modified.
134
135

STDIN

137       Not used.
138

INPUT FILES

140       None.
141

ENVIRONMENT VARIABLES

143       The  following  environment  variables  shall  affect  the execution of
144       touch:
145
146       LANG   Provide a default value for the  internationalization  variables
147              that  are  unset  or  null.  (See the Base Definitions volume of
148              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
149              ables  for the precedence of internationalization variables used
150              to determine the values of locale categories.)
151
152       LC_ALL If set to a non-empty string value, override the values  of  all
153              the other internationalization variables.
154
155       LC_CTYPE
156              Determine  the  locale  for  the  interpretation of sequences of
157              bytes of text data as characters (for  example,  single-byte  as
158              opposed to multi-byte characters in arguments).
159
160       LC_MESSAGES
161              Determine  the  locale  that should be used to affect the format
162              and contents of diagnostic messages written to standard error.
163
164       NLSPATH
165              Determine the location of message catalogs for the processing of
166              LC_MESSAGES .
167
168       TZ     Determine  the  timezone  to  be  used for interpreting the time
169              option-argument. If TZ is unset or null, an unspecified  default
170              timezone shall be used.
171
172

ASYNCHRONOUS EVENTS

174       Default.
175

STDOUT

177       Not used.
178

STDERR

180       The standard error shall be used only for diagnostic messages.
181

OUTPUT FILES

183       None.
184

EXTENDED DESCRIPTION

186       None.
187

EXIT STATUS

189       The following exit values shall be returned:
190
191        0     The utility executed successfully and all requested changes were
192              made.
193
194       >0     An error occurred.
195
196

CONSEQUENCES OF ERRORS

198       Default.
199
200       The following sections are informative.
201

APPLICATION USAGE

203       The interpretation of time is taken to be seconds since the Epoch  (see
204       the Base Definitions volume of IEEE Std 1003.1-2001, Section 4.14, Sec‐
205       onds Since the Epoch). It should be noted that implementations conform‐
206       ing to the System Interfaces volume of IEEE Std 1003.1-2001 do not take
207       leap seconds into account when computing seconds since the Epoch.  When
208       SS=60 is used, the resulting time always refers to 1 plus seconds since
209       the Epoch for a time when SS=59.
210
211       Although the -t time option-argument  specifies  values  in  1969,  the
212       access  time  and modification time fields are defined in terms of sec‐
213       onds since the Epoch (00:00:00  on  1  January  1970  UTC).  Therefore,
214       depending  on  the  value  of TZ when touch is run, there is never more
215       than a few valid hours in 1969 and there need not be any valid times in
216       1969.
217
218       One ambiguous situation occurs if -t time is not specified, -r ref_file
219       is not specified, and the first operand is an eight or ten-digit  deci‐
220       mal number. A portable script can avoid this problem by using:
221
222
223              touch -- file
224
225       or:
226
227
228              touch ./file
229
230       in this case.
231

EXAMPLES

233       None.
234

RATIONALE

236       The  functionality of touch is described almost entirely through refer‐
237       ences   to   functions   in   the   System   Interfaces    volume    of
238       IEEE Std 1003.1-2001.  In  this  way, there is no duplication of effort
239       required for describing such side effects as the relationship  of  user
240       IDs to the user database, permissions, and so on.
241
242       There  are  some  significant  differences between the touch utility in
243       this volume of IEEE Std 1003.1-2001 and those in System V and BSD  sys‐
244       tems. They are upwards-compatible for historical applications from both
245       implementations:
246
247        1. In System V, an ambiguity exists when a pathname that is a  decimal
248           number  leads  the operands; it is treated as a time value. In BSD,
249           no time value is allowed; files may only be touched to the  current
250           time.  The  -t time construct solves these problems for future con‐
251           forming applications (note that the -t  option  is  not  historical
252           practice).
253
254        2. The  inclusion  of the century digits, CC, is also new. Note that a
255           ten-digit time value is treated as if YY, and not CC,  were  speci‐
256           fied.  The  caveat about the range of dates following the Epoch was
257           included as recognition that some implementations are not  able  to
258           represent  dates beyond 18 January 2038 because they use signed int
259           as a time holder.
260
261       The -r option was added because several comments requested  this  capa‐
262       bility.  This option was named -f in an early proposal, but was changed
263       because the -f option is used in the BSD version of touch with  a  dif‐
264       ferent meaning.
265
266       At  least  one  historical implementation of touch incremented the exit
267       code if -c was specified and the file did not  exist.  This  volume  of
268       IEEE Std 1003.1-2001 requires exit status zero if no errors occur.
269

FUTURE DIRECTIONS

271       Applications should use the -r or -t options.
272

SEE ALSO

274       date,  the  System  Interfaces volume of IEEE Std 1003.1-2001, creat(),
275       time(), utime(), the Base Definitions volume  of  IEEE Std 1003.1-2001,
276       <sys/stat.h>
277
279       Portions  of  this text are reprinted and reproduced in electronic form
280       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
281       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
282       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
283       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
284       event of any discrepancy between this version and the original IEEE and
285       The  Open Group Standard, the original IEEE and The Open Group Standard
286       is the referee document. The original Standard can be  obtained  online
287       at http://www.opengroup.org/unix/online.html .
288
289
290
291IEEE/The Open Group                  2003                            TOUCH(1P)
Impressum