touch for filesystem
Creates one or more files.
Signature
> touch {flags} ...rest
Flags
--reference, -r {path}: Use the access and modification times of the reference file/directory instead of the current time--timestamp, -t {datetime}: Use the given timestamp instead of the current time--date, -d {string}: Use the given time instead of the current time. This can be a full timestamp or it can be relative to either the current time or reference file time (if given). For more information, see https://www.gnu.org/software/coreutils/manual/html_node/touch-invocation.html--modified, -m: Change only the modification time (if used with -a, access time is changed too)--access, -a: Change only the access time (if used with -m, modification time is changed too)--no-create, -c: Don't create the file if it doesn't exist--no-deref, -s: Affect each symbolic link instead of any referenced file (only for systems that can change the timestamps of a symlink). Ignored if touching stdout
Parameters
...rest: The file(s) to create. '-' is used to represent stdout.
Input/output types:
| input | output |
|---|---|
| nothing | nothing |
Examples
Creates "fixture.json"
> touch fixture.jsonCreates files a, b and c
> touch a b cChanges the last modified time of "fixture.json" to today's date
> touch -m fixture.jsonChanges the last modified and accessed time of all files with the .json extension to today's date
> touch *.jsonChanges the last accessed and modified times of files a, b and c to the current time but yesterday
> touch -d "yesterday" a b cChanges the last modified time of files d and e to "fixture.json"'s last modified time
> touch -m -r fixture.json d eChanges the last accessed time of "fixture.json" to a datetime
> touch -a -t 2019-08-24T12:30:30 fixture.jsonChange the last accessed and modified times of stdout
> touch -Changes the last accessed and modified times of file a to 1 month before "fixture.json"'s last modified time
> touch -r fixture.json -d "-1 month" a