1.\"	$OpenBSD: touch.1,v 1.10 2005/04/20 19:13:53 otto 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 April 28, 1995
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.Op Fl r Ar file
46.Op Fl t Ar [[CC]YY]MMDDhhmm[.SS]
47.Ar file Op Ar ...
48.Sh DESCRIPTION
49The
50.Nm
51utility sets the modification and access times of files to the
52current time of day.
53If the file doesn't exist, it is created with default permissions.
54.Pp
55The options are as follows:
56.Bl -tag -width Ds
57.It Fl a
58Change the access time of the file.
59The modification time of the file is not changed unless the
60.Fl m
61flag is also specified.
62.It Fl c
63Do not create the file if it does not exist.
64The
65.Nm
66utility does not treat this as an error.
67No error messages are displayed and the exit value is not affected.
68.It Fl m
69Change the modification time of the file.
70The access time of the file is not changed unless the
71.Fl a
72flag is also specified.
73.It Fl r
74Use the access and modification times from the specified file
75instead of the current time of day.
76.It Fl t
77Change the access and modification times to the specified time.
78The argument should be in the form
79.Dq [[CC]YY]MMDDhhmm[.SS]
80where each pair of letters represents the following:
81.Pp
82.Bl -tag -width Ds -compact -offset indent
83.It Ar CC
84The first two digits of the year (the century).
85.It Ar YY
86The second two digits of the year.
87If
88.Dq YY
89is specified, but
90.Dq CC
91is not, a value for
92.Dq YY
93between 69 and 99 results in a
94.Dq CC
95value of 19.
96Otherwise, a
97.Dq CC
98value of 20 is used.
99.It Ar MM
100The month of the year, from 1 to 12.
101.It Ar DD
102The day of the month, from 1 to 31.
103.It Ar hh
104The hour of the day, from 0 to 23.
105.It Ar mm
106The minute of the hour, from 0 to 59.
107.It Ar SS
108The second of the minute, from 0 to 61.
109.El
110.Pp
111If the
112.Dq CC
113and
114.Dq YY
115letter pairs are not specified, the values default to the current
116year.
117If the
118.Dq SS
119letter pair is not specified, the value defaults to 0.
120.El
121.Pp
122The
123.Nm
124utility exits 0 on success or >0 if an error occurred.
125.Sh SEE ALSO
126.Xr utimes 2
127.Sh STANDARDS
128The obsolescent form of
129.Nm touch ,
130where a time format is specified as the first argument, is supported.
131When no
132.Fl r
133or
134.Fl t
135option is specified, there are at least two arguments, and the first
136argument is a string of digits either eight or ten characters in length,
137the first argument is interpreted as a time specification of the form
138.Dq MMDDhhmm[YY] .
139.Pp
140The
141.Dq MM ,
142.Dq DD ,
143.Dq hh
144and
145.Dq mm
146letter pairs are treated as their counterparts specified to the
147.Fl t
148option.
149If the
150.Dq YY
151letter pair is in the range 69 to 99, the year is set from 1969 to 1999;
152otherwise, the year is set in the 21st century.
153.Pp
154The
155.Nm
156utility is expected to be a superset of the
157.St -p1003.2
158specification.
159.Sh HISTORY
160A
161.Nm
162utility appeared in
163.At v7 .
164