GNU Info

Info Node: (fileutils.info)touch invocation

(fileutils.info)touch invocation


Prev: chmod invocation Up: Changing file attributes
Enter node , (file) or (file)node

`touch': Change file timestamps
===============================

   `touch' changes the access and/or modification times of the
specified files.  Synopsis:

     touch [OPTION]... FILE...

   If the first FILE would be a valid argument to the `-t' option and
no timestamp is given with any of the `-d', `-r', or `-t' options and
the `--' argument is not given, that argument is interpreted as the
time for the other files instead of as a file name.  Warning: this
usage is obsolescent, and future versions of POSIX will require that
support for it be withdrawn.  Use `-t' instead.

   Any FILE that does not exist is created empty.

   If changing both the access and modification times to the current
time, `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.

   Although `touch' provides options for changing two of the times -
the times of last access and modification - of a file, there is actually
a third one as well: the inode change time.  This is often referred to
as a file's `ctime'.  The inode change time represents the time when
the file's meta-information last changed. One common example of this is
when the permissions of a file change.  Changing the permissions
doesn't access the file, so the atime doesn't change, nor does it
modify the file, so the mtime doesn't change.  Yet, something about the
file itself has changed, and this must be noted somewhere.  This is the
job of the ctime field.  This is necessary, so that, for example, a
backup program can make a fresh copy of the file, including the new
permissions value.  Another operation that modifies a file's ctime
without affecting the others is renaming.  In any case, it is not
possible, in normal operations, for a user to change the ctime field to
a user-specified value.

   The program accepts the following options.  Also see Note: Common
options.

`-a'
`--time=atime'
`--time=access'
`--time=use'
     Change the access time only.

`-c'
`--no-create'
     Do not create files that do not exist.

`-d'
`--date=time'
     Use TIME instead of the current time.  It can contain month names,
     timezones, `am' and `pm', etc.  Note: Date input formats.

`-f'
     Ignored; for compatibility with BSD versions of `touch'.

`-m'
`--time=mtime'
`--time=modify'
     Change the modification time only.

`-r FILE'
`--reference=FILE'
     Use the times of the reference FILE instead of the current time.

`-t [[CC]YY]MMDDhhmm[.ss]'
     Use the argument (optional four-digit or two-digit years, months,
     days, hours, minutes, optional seconds) instead of the current
     time.  If the year is specified with only two digits, then CC is
     20 for years in the range 0 ... 68, and 19 for years in 69 ... 99.
     If no digits of the year are specified, the argument is
     interpreted as a date in the current year.


automatically generated by info2www version 1.2.2.9