touch Create empty files or change file timestamps
Creates an empty file if the name does not exist yet. If it does exist, touch updates its access and modification times without changing the contents. You reach for it to make placeholder files or to fake or fix a file's date.
Synopsis
touch [OPTION]... FILE...
touch -t [[CC]YY]MMDDhhmm[.ss] FILE...
Common options
| Option or form | What it does |
|---|---|
-c | Do not create the file if it does not exist. No error is shown |
-t | Set the time to [[CC]YY]MMDDhhmm[.ss], for example 202601151030 for 15 January 2026 at 10:30 |
-d | Set the time from a date string such as "2026-01-15 10:30:00". Accepted formats differ between macOS and GNU/Linux (see notes) |
-r | Copy the times from another file instead of using the current time |
-a | Change only the access time |
-m | Change only the modification time |
-h | If the file is a symbolic link, change the link itself, not the file it points to. Implies -c |
Examples
touch new.txt
touch one.txt two.txt three.txt
touch -c notes.txt missing.txt
touch -t 202601151030 notes.txt
touch -r notes.txt copy.txt
touch -t 202601151030.45 app.log
Notes
- The -t format is [[CC]YY]MMDDhhmm[.ss]. The month comes first, then day, hour and minute, and the seconds go after a dot. 202601151030 means 2026-01-15 10:30. If you leave off the year, the current year is used.
- -d is not portable. GNU touch accepts free text such as "yesterday" or "2 hours ago". macOS touch rejects those and only accepts YYYY-MM-DDThh:mm:SS (a space can replace the T). Use -t in scripts that must run on both.
- touch never changes file contents. An existing file keeps its data, which makes touch safe to run on files you care about.
- A typo in a file name quietly creates a new empty file. Use -c when you only want to update files that already exist.
- Build tools such as make compare modification times, which is why touching a source file forces a rebuild.
See also
Last reviewed 2026-10-07.