Linux创建文件修改目录的时间属性touch命令
本帖最后由 sunsili 于 2021-8-14 17:18 编辑touch命令主要有两个功能:
[*]将已存在文件的时间更改为当前系统时间
[*]创建一个空的文件
不会用的命令首先touch --help
常见参数详解:-achange only the access time
-c, --no-create do not create any files-d, --date=STRING parse STRING and use it instead of current time
-f (ignored)
-h, --no-dereference affecteach symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink)
-m change only the modification time-r, --reference=FILE use this file's times instead of current time
-t STAMP use [YY]MMDDhhmm[.ss] instead of current time--time=WORD change the specified time: WORD is access, atime, oruse:equivalent to -a WORD is modify or mtime: equivalent to -m
参数说明:
[*]a 改变档案的读取时间记录。
[*]m 改变档案的修改时间记录。
[*]c 假如目的档案不存在,不会建立新的档案。与 --no-create 的效果一样。
[*]f 不使用,是为了与其他 unix 系统的相容性而保留。
[*]r 使用参考档的时间记录,与 --file 的效果一样。
[*]d 设定时间与日期,可以使用各种不同的格式。
[*]t 设定档案的时间记录,格式与 date 指令相同。
[*]--no-create 不会建立新档案。
[*]--help 列出指令格式。
[*]--version 列出版本讯息。
二、实战#创建一个不存在的空文件,如果存在无影响
#创建一个不存在的空文件,如果存在无影响
touch t1.txt
# 改变文件的时间戳
touch -t 202010091130 t1.txt
ll
-rw-r--r--. 1 root root 4 Oct9 11:30 t1.txt
页:
[1]