You are here: >

Linux and Unix touch

touch commandAbout touch
touch syntax
touch examples
Related commands
Linux and Unix main page

About touch

touch changes file timestamps.


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.

touch syntax

touch [OPTION]... FILE...


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.

touch 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.

date — Output the current date and time.