touch

v0.0.28
touch [OPTION]... [USER]

Update the access and modification times of each FILE to the current time.

Options

--help

Print help information.

-a

change only the access time

-t <STAMP>

use [[CC]YY]MMDDhhmm[.ss] instead of the current time

--date=<STRING>, -d <STRING>

parse argument and use it instead of current time

-m

change only the modification time

--no-create, -c

do not create any files

--no-dereference, -h

affect each symbolic link instead of any referenced file (only for systems that can change the timestamps of a symlink)

--reference=<FILE>, -r <FILE>

use this file's times instead of the current time

--time=<WORD>

change only the specified time: "access", "atime", or "use" are equivalent to -a; "modify" or "mtime" are equivalent to -m

Examples

Create specific files:

touch {{path/to/file1 path/to/file2 ...}}

Set the file [a]ccess or [m]odification times to the current one and don't [c]reate file if it doesn't exist:

touch -c -{{a|m}} {{path/to/file1 path/to/file2 ...}}

Set the file [t]ime to a specific value and don't [c]reate file if it doesn't exist:

touch -c -t {{YYYYMMDDHHMM.SS}} {{path/to/file1 path/to/file2 ...}}

Set the files' timestamp to the [r]eference file's timestamp, and do not [c]reate the file if it does not exist:

touch -c -r {{path/to/reference_file}} {{path/to/file1 path/to/file2 ...}}

The examples are provided by the tldr-pages project under the CC BY 4.0 License.

Please note that, as uutils is a work in progress, some examples might fail.