1.\" $NetBSD: touch.1,v 1.25 2012/10/24 02:46:25 pgoyette 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 October 22, 2012 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 61. 129.El 130.Pp 131If the 132.Dq CC 133and 134.Dq YY 135letter pairs are not specified, the values default to the current 136year. 137If the 138.Dq SS 139letter pair is not specified, the value defaults to 0. 140.El 141.Pp 142The 143.Fl d , 144.Fl r , 145and 146.Fl t 147options are mutually exclusive. 148If more than one of these options is present, the last one is used. 149.Sh EXIT STATUS 150.Ex -std 151.Sh COMPATIBILITY 152The obsolescent form of 153.Nm , 154where a time format is specified as the first argument, is supported. 155When no 156.Fl d , 157.Fl r , 158or 159.Fl t 160option is specified, there are at least two arguments, and the first 161argument is a string of digits either eight or ten characters in length, 162the first argument is interpreted as a time specification of the form 163.Dq MMDDhhmm[YY] . 164.Pp 165The 166.Dq MM , 167.Dq DD , 168.Dq hh 169and 170.Dq mm 171letter pairs are treated as their counterparts specified to the 172.Fl t 173option. 174If the 175.Dq YY 176letter pair is in the range 69 to 99, the year is set to 1969 to 1999, 177otherwise, the year is set in the 21st century. 178.Sh SEE ALSO 179.Xr utimes 2 180.Sh STANDARDS 181The 182.Nm 183utility is expected to be a superset of the 184.St -p1003.2 185specification. 186.Sh HISTORY 187A 188.Nm 189utility appeared in 190.At v7 . 191.Sh BUGS 192A symbolic link can't be a reference file of access and/or modification time. 193