touch for filesystem

Creates one or more files.

Signature

> touch {flags} ...rest

Flags

  • --reference, -r {string}: change the file or directory time to the time of the reference file/directory
  • --modified, -m: change the modification time of the file or directory. If no timestamp, date or reference file/directory is given, the current time is used
  • --access, -a: change the access time of the file or directory. If no timestamp, date or reference file/directory is given, the current time is used
  • --no-create, -c: do not create the file if it does not exist

Parameters

  • ...rest: The file(s) to create.

Input/output types:

inputoutput
nothingnothing

Examples

Creates "fixture.json"

> touch fixture.json

Creates files a, b and c

> touch a b c

Changes the last modified time of "fixture.json" to today's date

> touch -m fixture.json

Changes the last modified time of files a, b and c to a date

> touch -m -d "yesterday" a b c

Changes the last modified time of file d and e to "fixture.json"'s last modified time

> touch -m -r fixture.json d e

Changes the last accessed time of "fixture.json" to a date

> touch -a -d "August 24, 2019; 12:30:30" fixture.json