touch - command in linux
Updates the access time and modification time of each FILE to the current time.
filename if not exist will be created with empty, if option -c or -h is supplied it will not create.
filename string of - is handled differently and causes touch to change the times of the file associated with standard output.
syntax
touch [filename]
example
touch myfile.txt
if file present, it will update access time and modification time to current time, otherwise it will create a new file.
file will not be created if not exists
touch -c myfile.txt
Option | Description |
---|---|
-a | update only access time of the file |
-c, --no-create | dont create file if not exists |
-d, --date=STRING | updates with date-time supplied in STRING instead of current time |
-h, --no-dereference | |
-m | update only modification time of the file |
-r, --reference=FILE | use the referenced file timestamp instead of current time |
-t STAMP | update with [[CC]YY]MMDDhhmm[.ss] time instead of current time |
--time=WORD | update the specified time: WORD is access, atime |
--help | displays help |