Unix Manual Pages

A History of Unix

Unix in Summary

An introductory tutorial on Unix...


Selecting a Shell

Regular Expressions...

Perl and Unix...

Help with vi...

Shell scripting...


The 10 Unix commands every beginner needs to know...

The 10 most misunderstood commands...

The 62 Core Commands

Commands by Category

Alphabetic list of commands...


Copyright/Copyleft info...

touch





DESCRIPTION
change file access and modification times
SYNOPSIS
touch [-acm] [-r file] [-t time] [date_time] file ...
OPTIONS
-a
Change the access time of the file. The modification time of the file is not changed unless the -m flag is also specified.
-c
Do not create the file if it does not exist. Do not write any diagnostic messages concerning this condition.
-m
Change the modification time of the file. Do not change the access time unless -a is also specified.
-r file
Use the access and modifications times from the specified file instead of the current time of day.
-t time
Change the access and modification times to the specified time. The argument should be in the form ``[[CC]YY]MMDDhhmm[.SS]'' where each pair of letters represents the following:
CC
The first two digits of the year (the century).
YY The second two digits of the year.
MM The month of the year, from 1 to 12.
DD The day of the month, from 1 to 31.
hh The hour of the day, from 0 to 23.
mm The minute of the hour, from 0 to 59.
SS The second of the minute, from 0 to 61.
Both CC and YY are optional. If neither is given, the current year will be assumed. If YY is specified, but CC is not, CC will be derived as follows:
  • If YY is: 69-99, CC becomes: 19
  • If YY is: 00-38, CC becomes: 20
  • If YY is: 39-68, CC becomes: ERROR
If the ``CC'' and ``YY'' letter pairs are not specified, the values default to the current year. The range for SS is [00-61] rather than [00-59] because of leap seconds. If SS is 60 or 61, and the resulting time, as affected by the TZ environment variable, does not refer to a leap second, the resulting time will be one or two seconds after a time where SS is 59. If SS is not given, it is assumed to be 0.
-
ENVIRONMENT VARIABLES
TZ
EXITING
The touch utility exits 0 on success, and >0 if an error occurs.
The touch utility sets the modification and access times of files to the current time of day. If the file doesn't exist, it is created with default permissions.
The range of valid times is the Epoch to January 18, 2038.
If the resulting time value precedes or excedes the Epoch, touch will exit immediately with an error status.
© 1999-2004 Matchstick Consulting