Linux and Unix touch

Quick links

About touch
Syntax
Examples
Related commands
Linux and Unix main page

About touch

touch changes file timestamps.

Syntax

touch [OPTION]... FILE...

Description

The touch command updates the access and modification times of each FILE to the current system time.

If you specify a FILE that does not already exist, touch creates an empty file with that name (unless the -c or -h options are specified; see below).

If the FILE argument is a dash ("-") is handled specially and causes touch to change the times of the file associated with standard output.

Options

In the options below, arguments to long options are mandatory for short options as well:

-a Change only the access time.
-c, --no-create Do not create any files.
-d, --date=STRING Parse the string STRING and use it instead of current time.
-f Ignored, but included for compatibility reasons.
-h, --no-dereference Affect each symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink).
-m Change only the modification time.
-r, --reference=FILE Use this FILE's times instead of current time.
-t STAMP Use [[CC]YY]MMDDhhmm[.ss] instead of current time.
--time=WORD Change the specified time: WORD is access, atime, or use; or modify (equivalent to -a WORD), or mtime (equivalent to -m).
--help Display a help message, and exit.
--version Display version information, and exit.

Note that the -d and -t options accept different time-date formats.

Examples

touch file.txt

If file.txt exists, touch updates its access and modification times to the current time. If file.txt doesn't exist, it is created as a new, empty file.

Related commands

date — Output the current date and time.