touch changes the modification time, access time or both of each
file. The modification time is the
st_mtime
member of the
stat(2) information and the access time is the
st_atime
member. On most systems the file status change time is always set to the current time when either the access or modification times
are changed.
If neither the --reference nor the --time options are specified then the time used will be the date operand or
the current time if date is omitted.
If the date operand consists of 4, 6, 8, 10 or 12 digits followed by an optional . and two digits then it is
interpreted as: HHMM.SS, ddHHMM.SS, mmddHHMM.SS, mmddHHMMyy.SS or yymmddHHMM.SS, or mmddHHMMccyy.SS
or ccyymmddHHMM.SS. Conflicting standards and practice allow a leading or trailing 2 or 4 digit year for the 10 and 12
digit forms; the X/Open leading form is used to disambiguate (date(1) uses the
trailing form.) Avoid the 10 digit form to avoid confusion. The digit fields are:
- cc
- Century - 1, 19-20.
- yy
- Year in century, 00-99.
- mm
- Month, 01-12.
- dd
- Day of month, 01-31.
- HH
- Hour, 00-23.
- MM
- Minute, 00-59.
- SS
- Seconds, 00-60.
Some systems or file system types may limit the range of times that can be set. These limitations may not show up until a
subsequent
stat(2) call (yes, the time can be set but not checked!) Upper
limits of <0xffffffff and <0x7fffffff have been observed.