xref: /openbsd/usr.bin/touch/touch.1 (revision 09467b48)
1.\"	$OpenBSD: touch.1,v 1.35 2015/09/25 17:02:57 schwarze Exp $
2.\"	$NetBSD: touch.1,v 1.8 1995/08/31 22:10:05 jtc Exp $
3.\"
4.\" Copyright (c) 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" the Institute of Electrical and Electronics Engineers, Inc.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)touch.1	8.3 (Berkeley) 4/28/95
35.\"
36.Dd $Mdocdate: September 25 2015 $
37.Dt TOUCH 1
38.Os
39.Sh NAME
40.Nm touch
41.Nd change file access and modification times
42.Sh SYNOPSIS
43.Nm touch
44.Op Fl acm
45.Oo Fl d
46.Sm off
47.Ar ccyy No - Ar mm No - Ar dd Cm T Ar HH : MM : SS Oo \&. Ar frac Oc Op Cm Z
48.Sm on
49.Oc
50.Op Fl r Ar file
51.Op Fl t Oo Oo Ar cc Oc Ns Ar yy Oc Ns Ar mmddHHMM Ns Op Pf . Ar SS
52.Ar
53.Sh DESCRIPTION
54The
55.Nm
56utility sets the modification and access times of files to the
57current time of day.
58If the file doesn't exist, it is created with default permissions.
59.Pp
60The options are as follows:
61.Bl -tag -width Ds
62.It Fl a
63Change the access time of the file.
64The modification time of the file is not changed unless the
65.Fl m
66flag is also specified.
67.It Fl c
68Do not create the file if it does not exist.
69The
70.Nm
71utility does not treat this as an error.
72No error messages are displayed and the exit value is not affected.
73.It Xo Fl d
74.Sm off
75.Ar ccyy No - Ar mm No - Ar dd Cm T Ar HH : MM : SS Oo \&. Ar frac Oc Op Cm Z
76.Sm on
77.Xc
78Change the access and modification times to the specified time,
79in a format compliant with the
80.St -iso8601
81standard.
82The parts of the argument represent the following:
83.Pp
84.Bl -tag -width .frac -compact -offset indent
85.It Ar ccyy
86Year.
87.It Ar mm
88Month:
89a number from 1 to 12.
90.It Ar dd
91Day:
92a number from 1 to 31.
93.It Cm T
94Either the capital letter
95.Sq T
96or a single space.
97If a space is used, the argument should be quoted to
98prevent the shell from splitting it into multiple words.
99.It Ar HH
100Hour:
101a number from 0 to 23.
102.It Ar MM
103Minute:
104a number from 0 to 59.
105.It Ar SS
106Second:
107a number from 0 to 60
108(permitting a leap second).
109.It Ar frac
110The decimal fraction of the second,
111either a period or comma,
112followed by one or more decimal digits.
113.It Cm Z
114The timezone specifier: a capital letter
115.Sq Z
116indicating that the time is in UTC.
117If not specified, the time is in the local timezone.
118.El
119.It Fl m
120Change the modification time of the file.
121The access time of the file is not changed unless the
122.Fl a
123flag is also specified.
124.It Fl r Ar file
125Use the access and modification times from the specified file
126instead of the current time of day.
127.It Fl t Oo Oo Ar cc Oc Ns Ar yy Oc Ns Ar mmddHHMM Ns Op Pf . Ar SS
128Change the access and modification times to the specified time,
129where the parts of the argument represent the following:
130.Pp
131.Bl -tag -width Ds -compact -offset indent
132.It Ar ccyy
133Year.
134If yy is specified, but cc is not,
135a value for yy between 69 and 99 results in a cc value of 19.
136Otherwise, a cc value of 20 is used.
137.It Ar mm
138Month:
139a number from 1 to 12.
140.It Ar dd
141Day:
142a number from 1 to 31.
143.It Ar HH
144Hour:
145a number from 0 to 23.
146.It Ar MM
147Minute:
148a number from 0 to 59.
149.It Ar SS
150Second:
151a number from 0 to 60
152(permitting a leap second),
153preceded by a period.
154The default is 0.
155.El
156.El
157.Sh EXIT STATUS
158.Ex -std touch
159.Sh SEE ALSO
160.Xr date 1
161.Sh STANDARDS
162The
163.Nm
164utility is compliant with the
165.St -p1003.1-2008
166specification.
167.Pp
168The obsolescent form of
169.Nm touch ,
170where a time format is specified as the first argument, is supported.
171When no
172.Fl d , r ,
173or
174.Fl t
175option is specified, there are at least two arguments, and the first
176argument is a string of digits either eight or ten characters in length,
177the first argument is interpreted as a time specification of the form
178.Dq mmddHHMM[yy] .
179.Sh HISTORY
180A
181.Nm
182utility appeared in
183.At v7 .
184