1touch(1)                         User Commands                        touch(1)
2
3
4

NAME

6       touch, settime - change file access and modification times
7

SYNOPSIS

9       touch [-acm] [-r ref_file | -t time | -d date_time] file...
10
11
12       touch [-acm] [time_spec] file...
13
14
15       settime [-f ref_file] [time_spec] file...
16
17

DESCRIPTION

19       The  touch utility sets the access and modification times of each file.
20       The file operand is created if it does not already exist.
21
22
23       The time used can be specified by -t time, by -d date_time, by the cor‐
24       responding time fields of the file referenced by -r ref_file, or by the
25       time_spec operand. If none of these are specified, touch uses the  cur‐
26       rent time.
27
28
29       If  neither the -a nor -m options are specified, touch updates both the
30       modification and access times.
31
32
33       A user with write access to a file, but who is not  the  owner  of  the
34       file  or  a super-user, can change the modification and access times of
35       that file only to the current time. Attempts to  set  a  specific  time
36       with touch results in an error.
37
38
39       The settime utility is equivalent to touch -c [time_spec] file.
40

OPTIONS

42       The following options are supported in the touch and settime utilities:
43
44   touch
45       The following options are supported for the touch utility:
46
47       -a
48
49           Changes  the  access time of file. Does not change the modification
50           time unless -m is also specified.
51
52
53       -c
54
55           Does not create a specified file if it does  not  exist.  Does  not
56           write any diagnostic messages concerning this condition.
57
58
59       -d date_time
60
61           Uses  the  specified  date_time  instead  of  the current time. The
62           option-argument must be a string of the form:
63
64             YYYY-MM-DDThh:mm:SS[.frac][tz]
65
66
67           or
68
69             YYYY-MM-DDThh:mm:SS[,frac][tz]
70
71
72           where
73
74               o      YYYY is at least four decimal digits giving the year
75
76               o      MM, DD, hh, mm, and SS are as with -t time
77
78               o      T is either the letter T or a single SPACE character
79
80               o      [.frac] and [,frac] are either empty, or a period (.) or
81                      a  comma (,) respectively, followed by one or more deci‐
82                      mal digits, specifying a fractional second
83
84               o      [tz] is either empty, signifying local time, or the let‐
85                      ter  Z,  signifying UTC. If [tz] is empty, the resulting
86                      time is affected by the  value  of  the  TZ  environment
87                      variable
88
89
90       -m
91
92           Changes  the  modification time of file. Does not change the access
93           time unless -a is also specified.
94
95
96       -r ref_file
97
98           Uses the corresponding times of the file named by ref_file  instead
99           of the current time.
100
101
102       -t time
103
104           Uses the specified time instead of the current time. time is a dec‐
105           imal number of the form:
106
107             [[CC]YY]MMDDhhmm[.SS]
108
109
110           where each two digits represent the following:
111
112           MM
113
114               The month of the year [01-12].
115
116
117           DD
118
119               The day of the month [01-31].
120
121
122           hh
123
124               The hour of the day [00-23].
125
126
127           mm
128
129               The minute of the hour [00-59].
130
131
132           CC
133
134               The first two digits of the year.
135
136
137           YY
138
139               The second two digits of the year.
140
141
142           SS
143
144               The second of the minute [00-61].
145
146           Both CC and YY are optional. If neither is given, the current  year
147           is  assumed.  If  YY  is specified, but CC is not, CC is derived as
148           follows:
149
150
151
152
153           ┌───────────────────────────────────────────────────────────┐
154           │         If YY is:                    CC becomes:          │
155           ├───────────────────────────────────────────────────────────┤
156           │69-99                         19                           │
157           │00-38                         20                           │
158           │39-68                         ERROR                        │
159           └───────────────────────────────────────────────────────────┘
160           The resulting time is affected by the value of the  TZ  environment
161           variable.  If  the  resulting  time value precedes the Epoch, touch
162           exits immediately with an error status. The range of valid times is
163           the Epoch to January 18, 2038.
164
165           The  range  for  SS  is [00-61] rather than [00-59] because of leap
166           seconds. If SS is 60 or 61, and the resulting time, as affected  by
167           the  TZ  environment variable, does not refer to a leap second, the
168           resulting time is one or two seconds after a time where SS  is  59.
169           If SS is not given, it is assumed to be 0.
170
171
172   settime
173       The following option is supported for the settime utility:
174
175       -f ref_file
176
177           Uses  the corresponding times of the file named by ref_file instead
178           of the current time.
179
180

OPERANDS

182       The following operands are supported for the touch and  settime  utili‐
183       ties:
184
185       file
186
187           A path name of a file whose times are to be modified.
188
189
190       time_spec
191
192           Uses  the specified time_spec instead of the current time. This op‐
193           erand is a decimal number of the form:
194
195             MMDDhhmm[YY]
196
197
198           where each two digits represent the following:
199
200           MM
201
202               The month of the year [01-12].
203
204
205           DD
206
207               The day of the month [01-31].
208
209
210           hh
211
212               The hour of the day [00-23].
213
214
215           mm
216
217               The minute of the hour [00-59].
218
219
220           YY
221
222               The second two digits of the year.
223
224               YY is optional. If it is omitted, the current year is  assumed.
225               If YY is specified, the year is derived as follows:
226
227
228
229
230
231           ┌───────────────────────────────────────────────────────────┐
232           │            YY                     Corresponding Year      │
233           │69-99                         1969-1999                    │
234           │00-38                         2000-2038                    │
235           │39-68                         ERROR                        │
236           └───────────────────────────────────────────────────────────┘
237           If  no  -d, -r, or -toption is specified, at least two operands are
238           specified, and the first operand is an eight- or ten-digit  decimal
239           integer,  the  first  operand is assumed to be a time_spec operand.
240           Otherwise, the first operand is assumed to be a file operand.
241
242

USAGE

244       See largefile(5) for the description of  the  behavior  of  touch  when
245       encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
246

ENVIRONMENT VARIABLES

248       See  environ(5) for descriptions of the following environment variables
249       that affect  the  execution  of  touch:  LANG,  LC_ALL,  LANG,  LC_ALL,
250       LC_CTYPE, LC_MESSAGES, and NLSPATH.
251
252       TZ
253
254           Determine  the  timezone  to  be  used for interpreting the time or
255           date_time option-argument or the time_spec operand.
256
257

EXIT STATUS

259       The following exit values are returned:
260
261       0
262
263           The touch utility executed successfully and all  requested  changes
264           were made.
265
266
267       >0
268
269           An  error  occurred. The touch utility returned the number of files
270           for which the times could not be successfully modified.
271
272

ATTRIBUTES

274       See attributes(5) for descriptions of the following attributes:
275
276
277
278
279       ┌─────────────────────────────┬─────────────────────────────┐
280       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
281       ├─────────────────────────────┼─────────────────────────────┤
282       │Availability                 │SUNWcsu                      │
283       ├─────────────────────────────┼─────────────────────────────┤
284       │CSI                          │Enabled                      │
285       ├─────────────────────────────┼─────────────────────────────┤
286       │Interface Stability          │Committed                    │
287       ├─────────────────────────────┼─────────────────────────────┤
288       │Standard                     │See standards(5).            │
289       └─────────────────────────────┴─────────────────────────────┘
290

SEE ALSO

292       futimens(2), stat(2), attributes(5),  environ(5),  largefile(5),  stan‐
293       dards(5)
294

NOTES

296       Users  familiar  with the BSD environment find that for the touch util‐
297       ity, the -f option is accepted but ignored. The -f option  is  unneces‐
298       sary  because touch succeeds for all files owned by the user regardless
299       of the permissions on the files.
300
301
302
303SunOS 5.11                        9 Sep 2009                          touch(1)
Impressum