[Next] [Previous] [Up] [Top] [Contents]

8.1 Working With Files

8.1.5 touch - create a file

The touch command can be used to create a new (empty) file or to update the last access date/time on an existing file. The command is used primarily when a script requires the pre-existence of a file (for example, to which to append information) or when the script is checking for last date or time a function was performed.


touch [options] [date_time] file

touch [options] [-t time] file

Common Options

-a change the access time of the file (SVR4 only)

-c don't create the file if it doesn't already exist

-f force the touch, regardless of read/write permissions

-m change the modification time of the file (SVR4 only)

-t time use the time specified, not the current time (SVR4 only)

When setting the "-t time" option it should be in the form:



CC first two digits of the year

YY second two digits of the year

MM month, 01-12

DD day of month, 01-31

hh hour of day, 00-23

mm minute, 00-59

SS second, 00-61

The date_time options has the form:


where these have the same meanings as above.

The date cannot be set to be before 1969 or after January 18, 2038.


To create a file:

% touch filename

Introduction to Unix - 14 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]