xref: /netbsd-src/usr.bin/touch/touch.1 (revision 181254a7b1bdde6873432bffef2d2decc4b5c22f)
1.\"	$NetBSD: touch.1,v 1.26 2016/12/24 15:49:18 abhinav Exp $
2.\"
3.\" Copyright (c) 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" the Institute of Electrical and Electronics Engineers, Inc.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. Neither the name of the University nor the names of its contributors
18.\"    may be used to endorse or promote products derived from this software
19.\"    without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
32.\"
33.\"     @(#)touch.1	8.3 (Berkeley) 4/28/95
34.\"
35.Dd December 24, 2016
36.Dt TOUCH 1
37.Os
38.Sh NAME
39.Nm touch
40.Nd change file access and modification times
41.Sh SYNOPSIS
42.Nm
43.Op Fl acfhm
44.Op Fl d Ar human-datetime
45.Op Fl Fl date Ar human-datetime
46.Op Fl r Ar file
47.Op Fl Fl reference Ar file
48.Op Fl t Ar datetime
49.Ar file ...
50.Sh DESCRIPTION
51The
52.Nm
53utility changes the access and modification times of files to the
54current time of day.
55If the file doesn't exist, it is created with default permissions.
56.Pp
57The following options are available:
58.Bl -tag -width "-d human-datetime"
59.It Fl a
60Change the access time of the file.
61The modification time of the file is not changed unless the
62.Fl m
63flag is also specified.
64.It Fl c
65Do not create the file if it does not exist.
66The
67.Nm
68utility does not treat this as an error.
69No error messages are displayed and the exit value is not affected.
70.It Fl d Ar human-datetime
71.It Fl Fl date Ar human-datetime
72Parse
73.Ar human-datetime
74using the human datetime parser
75.Xr parsedate 3 .
76.It Fl f
77This flag has no effect; it is accepted for compatibility reasons.
78.It Fl h
79If
80.Ar file
81is a symbolic link, access and/or modification time of the link is changed.
82This option implies
83.Fl c .
84.It Fl m
85Change the modification time of the file.
86The access time of the file is not changed unless the
87.Fl a
88flag is also specified.
89.It Fl r Ar file
90.It Fl Fl reference Ar file
91Use the access and modifications times from
92.Ar file
93instead of the current time of day.
94.It Fl t Ar datetime
95Change the access and modification times to the specified time.
96The argument
97.Ar datetime
98should be in the form
99.Dq [[CC]YY]MMDDhhmm[.SS]
100where each pair of letters represents the following:
101.Pp
102.Bl -tag -width Ds -compact -offset indent
103.It Ar CC
104The first two digits of the year (the century).
105.It Ar YY
106The second two digits of the year.
107If
108.Dq YY
109is specified, but
110.Dq CC
111is not, a value for
112.Dq YY
113between 69 and 99 results in a
114.Dq CC
115value of 19.
116Otherwise, a
117.Dq CC
118value of 20 is used.
119.It Ar MM
120The month of the year, from 1 to 12.
121.It Ar DD
122The day of the month, from 1 to 31.
123.It Ar hh
124The hour of the day, from 0 to 23.
125.It Ar mm
126The minute of the hour, from 0 to 59.
127.It Ar SS
128The second of the minute, from 0 to 60 (permitting leap seconds).
129If
130.Ar SS
131is 60 and the resulting time,
132as affected by the
133.Ev TZ
134environment variable,
135does not refer to a leap second,
136the resulting time is one second after a time where
137.Ar SS
138is 59.
139If
140.Ar SS
141is not given a value, it is assumed to be zero.
142.El
143.Pp
144If the
145.Dq CC
146and
147.Dq YY
148letter pairs are not specified, the values default to the current
149year.
150If the
151.Dq SS
152letter pair is not specified, the value defaults to 0.
153.El
154.Pp
155The
156.Fl d ,
157.Fl r ,
158and
159.Fl t
160options are mutually exclusive.
161If more than one of these options is present, the last one is used.
162.Sh ENVIRONMENT
163.Bl -tag -width -iTZ
164.It Ev TZ
165The timezone to be used for interpreting the
166.Ar datetime
167argument of the
168.Fl t
169option.
170.El
171.Sh EXIT STATUS
172.Ex -std
173.Sh COMPATIBILITY
174The obsolescent form of
175.Nm ,
176where a time format is specified as the first argument, is supported.
177When no
178.Fl d ,
179.Fl r ,
180or
181.Fl t
182option is specified, there are at least two arguments, and the first
183argument is a string of digits either eight or ten characters in length,
184the first argument is interpreted as a time specification of the form
185.Dq MMDDhhmm[YY] .
186.Pp
187The
188.Dq MM ,
189.Dq DD ,
190.Dq hh
191and
192.Dq mm
193letter pairs are treated as their counterparts specified to the
194.Fl t
195option.
196If the
197.Dq YY
198letter pair is in the range 69 to 99, the year is set to 1969 to 1999,
199otherwise, the year is set in the 21st century.
200.Sh SEE ALSO
201.Xr utimes 2 ,
202.Xr parsedate 3
203.Sh STANDARDS
204The
205.Nm
206utility is expected to be a superset of the
207.St -p1003.2
208specification.
209.Sh HISTORY
210A
211.Nm
212utility appeared in
213.At v7 .
214.Sh BUGS
215A symbolic link can't be a reference file of access and/or modification time.
216