2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright Andries Brouwer, Ragnar Hojland Espinosa and A. Wik, 1998.
|
|
|
|
.\"
|
|
|
|
.\" This file may be copied under the conditions described
|
|
|
|
.\" in the LDP GENERAL PUBLIC LICENSE, Version 1, September 1998
|
|
|
|
.\" that should have been distributed together with this file.
|
|
|
|
.\"
|
|
|
|
.TH TOUCH 1 1998-11 "GNU fileutils 4.0"
|
|
|
|
.SH NAME
|
|
|
|
touch \- change file timestamps
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B touch
|
|
|
|
.BI "[\-acm][\-r " ref_file "|\-t " time "] [\-\-] " file...
|
|
|
|
.sp
|
|
|
|
Obsolescent version:
|
|
|
|
.br
|
|
|
|
.B touch
|
|
|
|
.BI "[\-acm][" ugly_time "] " file...
|
|
|
|
.sp
|
|
|
|
GNU version:
|
|
|
|
.br
|
|
|
|
.B touch
|
|
|
|
.BI "[\-acfm] [\-r " file "] [\-t " decimtime ]
|
|
|
|
.BI "[\-d " time "] [\-\-time={atime,access,use,mtime,modify}]"
|
|
|
|
.BI "[\-\-date=" time "] [\-\-reference=" file ]
|
|
|
|
.BI "[\-\-no\-create] [\-\-help] [\-\-version] [\-\-] " file...
|
|
|
|
.SH DESCRIPTION
|
|
|
|
.B touch
|
|
|
|
changes the access and/or modification timestamps of each
|
|
|
|
specified
|
|
|
|
.IR file .
|
|
|
|
These timestamps are changed to the current time, unless
|
|
|
|
the \-r option is specified, in which case they are changed
|
|
|
|
to the corresponding timestamps of the file
|
|
|
|
.IR ref_file ,
|
|
|
|
or the \-t option is specified, in which case they are changed
|
|
|
|
to the specified
|
|
|
|
.IR time .
|
|
|
|
Both times are changed when neither or both of the \-a and \-m
|
|
|
|
options are given. Only the access or only the modification time
|
|
|
|
is changed when one of the options \-a and \-m is given.
|
|
|
|
If the file did not exist yet, it is created (as an empty file
|
|
|
|
with mode 0666, modified by the umask), unless the \-c option is given.
|
|
|
|
.SH "POSIX OPTIONS"
|
|
|
|
.TP
|
|
|
|
.B \-a
|
|
|
|
Change the access time of
|
|
|
|
.IR file .
|
|
|
|
.TP
|
|
|
|
.B \-c
|
|
|
|
Do not create
|
|
|
|
.IR file .
|
|
|
|
.TP
|
|
|
|
.B \-m
|
|
|
|
Change the modification time of
|
|
|
|
.IR file .
|
|
|
|
.TP
|
|
|
|
.BI "\-r " ref_file
|
|
|
|
Use the corresponding timestamp of
|
|
|
|
.I ref_file
|
|
|
|
as the new value for the changed timestamp(s).
|
|
|
|
.TP
|
|
|
|
.BI "\-t " time
|
|
|
|
Use the specified time as the new value for the changed timestamp(s).
|
|
|
|
The argument is a decimal number of the form
|
|
|
|
.br
|
|
|
|
.nf
|
|
|
|
[[CC]YY]MMDDhhmm[.SS]
|
|
|
|
.br
|
|
|
|
.fi
|
|
|
|
with the obvious meaning. If CC is not specified, the year CCYY
|
|
|
|
is taken to be in the range 1969-2068.
|
|
|
|
If SS is not specified, it is taken to be 0. It may be specified
|
|
|
|
in the range 0-61 so that it is possible to refer to leap seconds.
|
|
|
|
The resulting time is taken as a time for the time zone specified by
|
|
|
|
the environment variable TZ. It is an error if the resulting time
|
|
|
|
precedes 1 January 1970.
|
|
|
|
.TP
|
|
|
|
.B "\-\-"
|
|
|
|
Terminate option list.
|
|
|
|
.SH "POSIX DETAILS"
|
|
|
|
The second form of invocation has the disadvantage that there is
|
|
|
|
some ambiguity as to whether
|
|
|
|
.I ugly_time
|
|
|
|
is a time or a file argument. It is taken to be a time when
|
|
|
|
no \-r or \-t option is present, there are at least two arguments,
|
|
|
|
and the first argument is an eight- or ten-digit decimal integer.
|
|
|
|
The format of
|
|
|
|
.I ugly_time
|
|
|
|
is MMDDhhmm[yy], where an yy in the range 69-99 denotes a year
|
|
|
|
in the range 1969-1999, and an unspecified yy denotes the current year.
|
|
|
|
This form is obsolete.
|
|
|
|
.SH "GNU DETAILS"
|
|
|
|
If the first
|
|
|
|
.I file
|
|
|
|
would be a valid argument to the
|
|
|
|
.B "\-t"
|
|
|
|
option and no timestamp is given with any of the
|
|
|
|
.BR "\-d" ,
|
|
|
|
.BR "\-r"
|
|
|
|
or
|
|
|
|
.B "\-t"
|
|
|
|
options and the `\-\-' argument is not given, that argument is
|
2006-02-12 22:23:18 +00:00
|
|
|
interpreted as the time for the other files instead of as a filename.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
If changing both the access and modification times to the current
|
|
|
|
time,
|
|
|
|
.B touch
|
|
|
|
can change the timestamps for files that the user running it does
|
|
|
|
not own but has write permission for. Otherwise, the user must
|
|
|
|
own the files.
|
|
|
|
.SH "GNU OPTIONS"
|
|
|
|
.TP
|
|
|
|
.B "\-a, \-\-time=atime, \-\-time=access, \-\-time=use"
|
|
|
|
Change the access time only.
|
|
|
|
.TP
|
|
|
|
.B "\-c, \-\-no\-create"
|
|
|
|
Do not create files that do not exist.
|
|
|
|
.TP
|
|
|
|
.BI "\-d, \-\-date=" time
|
|
|
|
Use
|
|
|
|
.I time
|
|
|
|
instead of the current time. It can contain month names,
|
|
|
|
time zones, `am' and `pm', etc.
|
|
|
|
.TP
|
|
|
|
.B "\-f"
|
|
|
|
Ignored; for compatibility with BSD versions of
|
|
|
|
.BR touch (1).
|
|
|
|
.TP
|
|
|
|
.B "\-m, \-\-time=mtime, \-\-time=modify"
|
|
|
|
Change the modification time only.
|
|
|
|
.TP
|
|
|
|
.BI "\-r " file ", \-\-reference=" file
|
|
|
|
Use the times of the reference
|
|
|
|
.I file
|
|
|
|
instead of the current time.
|
|
|
|
.TP
|
|
|
|
.BI "\-t " decimtime
|
|
|
|
Here
|
|
|
|
.I decimtime
|
|
|
|
has the format MMDDhhmm[[CC]YY][.ss]
|
|
|
|
Use the argument (months, days, hours, minutes, optional century
|
|
|
|
and years, optional seconds) instead of the current time.
|
|
|
|
Note that this format violates the POSIX specification.
|
|
|
|
.SH "GNU STANDARD OPTIONS"
|
|
|
|
.TP
|
|
|
|
.B "\-\-help"
|
|
|
|
Print a usage message on standard output and exit successfully.
|
|
|
|
.TP
|
|
|
|
.B "\-\-version"
|
|
|
|
Print version information on standard output, then exit successfully.
|
|
|
|
.TP
|
|
|
|
.B "\-\-"
|
|
|
|
Terminate option list.
|
|
|
|
.SH ENVIRONMENT
|
|
|
|
The variable TZ is used to interpret explicitly given times.
|
|
|
|
The variables LANG, LC_ALL, LC_CTYPE and LC_MESSAGES have the
|
|
|
|
usual meaning.
|
|
|
|
.SH "CONFORMING TO"
|
2006-08-03 13:57:13 +00:00
|
|
|
POSIX.2 describes a syntax for the argument of the \-t option
|
2004-11-03 13:51:07 +00:00
|
|
|
that differs from that used by the GNU implementation.
|
|
|
|
.SH "EXAMPLE OF USE"
|
|
|
|
The command `\fItouch foo\fP' will create the file \fIfoo\fP
|
|
|
|
if it didn't exist, and change the time of last modification to now.
|
|
|
|
It is often used to guide the actions of
|
|
|
|
.BR make .
|
|
|
|
.SH NOTES
|
|
|
|
This page describes
|
|
|
|
.B touch
|
|
|
|
as found in the fileutils-4.0 package;
|
|
|
|
other versions may differ slightly.
|