touch
Files and directories
Usage
touch [file]Bumps a file's timestamps to now and creates it empty if it is missing; it never touches the contents.
Common flags
| Flag | Meaning |
|---|---|
| -a | Change only the access time |
| -m | Change only the modification time |
| -c | Do not create the file if it is missing |
| -r | Copy the timestamps from another file |
| -t | Set an explicit time as [[CC]YY]MMDDhhmm[.SS] |
| -d | GNU: set the time from a phrase such as -d yesterday |
Examples
touch notes.mdCreates it empty, or just bumps the time.
touch -t 202401011200 report.pdfSets the time to noon on 1 Jan 2024.
touch -r a.txt b.txtGives b.txt the same times as a.txt.
Moving, deleting and finding. Some of these do not ask twice, which is why -i becomes a habit.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does touch do?
Bumps a file's timestamps to now and creates it empty if it is missing; it never touches the contents.
Q. How do I type it?
touch [file] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
6 are listed here; the full set is in man touch. This command sits under Files and directories.
Related commands
man page: man touch