# stat main.c
Access: 2023-12-14 23:43:08.299761676 +0800
Modify: 2023-12-14 23:43:08.274761678 +0800
Change: 2023-12-14 23:43:08.274761678 +0800
Birth: -
# touch main.c
# stat main.c (all the three times changed.)
Access: 2023-12-14 23:43:37.956758479 +0800
Modify: 2023-12-14 23:43:37.893758486 +0800
Change: 2023-12-14 23:43:37.893758486 +0800
Birth: -
# for -a option,atime and ctime will change.
# for -m option,atime mtime,ctime all three will change.
我很困惑为什么 touch 命令也会改变 ctime?
touch changes the access and/or modification timestamps of the specified files.
(As you can see,only atime and mtime are mentioned.)
# options:
-a. Change the access timestamp only.
-m. Change the modification timestamp only.
# https://www.gnu.org/software/coreutils/manual/html_node/touch-invocation.html
所以我很困惑。
触摸命令之后,main.c 的内容与之前相同。
但是mtime已经改变了。(我无法理解。)
touch被指定为改变文件访问和修改时间;更改更改时间是更改文件元数据的副作用,而 touch 对此没有任何控制权(另请参阅 touch 使用的 futimens() 和 utimensat() 函数)。