touchx
Update the access and modification times of each FILE to the current time.
Mirrors GNU touch. Run it as touchx, or as gnux touchx.
Synopsis
touchx [OPTION]... FILE...GNU reference
Description
touchx sets the access and modification times of each FILE to the current time, creating an empty file for any FILE that does not exist unless -c is given. An existing file's contents are never changed. -a and -m (or --time) restrict the update to one of the two timestamps and leave the other exactly as it was. The time to apply can come from somewhere other than the clock: -d takes a date string (2024-01-02, '2024-01-02 15:04:05', an RFC 3339 timestamp, @SECONDS since the epoch, or now), -t takes a [[CC]YY]MMDDhhmm[.ss] stamp, and -r copies the times of another file. -h acts on a symbolic link itself rather than the file it points to.
Permissions
Setting a file's times to the current time needs write permission on it; setting them to any other time (-d, -t, -r) needs ownership of the file. Creating a missing file needs write and search permission on its directory. Changing the times of a symbolic link itself (-h) is only possible on Linux; elsewhere touchx reports the link rather than silently touching its target.
Use cases
- Creating an empty placeholder or marker file.
- Forcing a rebuild by making a source file newer than its outputs.
- Stamping files with a fixed time for reproducible archives.
- Copying timestamps from one file to another with
-r. - Refreshing the timestamps of existing files only, without creating strays, with
-c. - Recording when a step ran by touching a marker file that later steps compare against.
- Backdating a file with
-dor-ttotestretention or cleanup rules. - Changing only the access time (
-a) or only the modification time (-m).
Flags
-a, --access-time change only the access time
-d, --date STRING parse STRING and use it instead of current time
--help display this help and exit
-m, --modification-time change only the modification time
-c, --no-create do not create any files
-h, --no-dereference affect each symbolic link instead of any referenced file
-r, --reference FILE use this FILE's times instead of current time
-t, --stamp STAMP use [[CC]YY]MMDDhhmm[.ss] STAMP instead of current time
--time WORD change the specified time: WORD is access, atime, or use (like -a), or modify or mtime (like -m)
--version output version information and exitExamples
Create a file, or bump its timestamps if it exists
touchx notes.txtCreate several empty files at once
touchx a.txt b.txt c.txtUpdate timestamps without creating anything
touchx -c build/*.oSet only the modification time to a specific date
touchx -m -d '2024-01-02 15:04:05' report.pdfSet only the access time to now
touchx -a app.logChoose the timestamp by name with --time (access/atime/use or modify/mtime)
touchx --time=mtime app.logUse a [[CC]YY]MMDDhhmm[.ss] stamp
touchx -t 202401021504.05 report.pdfBackdate only the access time with a stamp
touchx -a -t 202001010000 app.logUse an RFC 3339 timestamp, or seconds since the epoch
touchx -d 2024-06-01T12:00:00Z release.txt && touchx -d @0 epoch.txtGive one file the timestamps of another
touchx -r original.jpg edited.jpgCopy just the modification time, and only to files that already exist
touchx -c -m -r original.jpg edited.jpg report.pdfStamp all sources with one fixed date for a reproducible archive
touchx -d 2024-01-01 src/*.goChange the times of a symbolic link itself, not its target (Linux only)
touchx -h -d 2024-01-01 link.txtCreate a marker file inside a new directory
mkdirx -p cache && touchx cache/.keepStamp files and list them with the gnux shell
gnux shell -c 'touchx -d 2024-01-01 a.txt b.txt && lsx -l a.txt b.txt'Options
Each option has a page of its own, with its usage and examples.
- -a, --access-time: Change only the access time.
- -d, --date: Parse STRING and use it instead of current time.
- -m, --modification-time: Change only the modification time.
- -c, --no-create: Do not create any files.
- -h, --no-dereference: Affect each symbolic
linkinstead of any referenced file. - -r, --reference: Use this FILE's times instead of current time.
- -t, --stamp: Use [[CC]YY]MMDDhhmm[.ss] STAMP instead of current time.
- --time: Change the specified time: WORD is access, atime, or use (like
-a), or modify or mtime (like-m).
Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
touchx --help # options, first examples, exit status
gnux help touchx # this page: the full manual
gnux help touchx --OPTION # one option in depth, with its examples