Article directory
1. Introduction to commands
The touch command is used to modify the access time, content modification time, and status change time of a file or directory. By default, if the file does not exist, it will be created.
2. Command format
touch [OPTION]... FILE...
Option description
-a
改变档案的访问时间
-c, --no-create
不创建任何文件
-d, --date=STRING
使用指定的时间修改文件时间属性,而非当前时间
-f
不使用,是为了与其他 Unix 系统的相容性而保留
-h, --no-dereference
只改变符号链接的时间属性,而不是链接的文件
-m
改变档案的修改时间
-r, --reference=FILE
使用参考文件的创建时间,而不是当前时间
-t STAMP
指定文件的创建时间而不是当前时间,时间 STAMP 格式与 date 命令相同
--help
显示帮助信息并退出
--version
显示版本信息并退出
3. Common examples
(1) If the target file does not exist, create a new file
touch filename
(2) Change the file time (recently accessed, recently modified and recently modified) to the current system time.
touch filename
references
[1] touch(1) manual