【问题标题】:how to set creation date & time with milliseconds to file?如何以毫秒为单位设置创建日期和时间到文件?
【发布时间】:2019-08-23 11:27:18
【问题描述】:

我正在尝试将创建日期和时间设置为以毫秒为单位的文件。但按我的方式行不通。

setfile -d "01/23/2000 12:00:00.099" file.txt
setfile -m "01/23/2001 12:00:00.499" file.txt

等等

这种方式只能从 Hours 设置为 seconds 。不是毫秒 这个怎么做 ??

【问题讨论】:

  • Apple 新的 APFS 文件系统可以支持纳秒以及它拥有的更多强大功能!所以当我看到某个地方应该存在如何用纳秒更改或更新文件的出生日期和时间时......哈哈,你的技术力量已经过时了! :-)

标签: bash macos shell unix milliseconds


【解决方案1】:

只需使用 coreutils touch:

touch --date '01/23/2000 12:00:00.099' file.txt

【讨论】:

  • 你在macos上测试过吗??
  • 没有。我根据手册和some research 如何使用touch 更改文件的创建日期。他们使用带有时间戳的touch -t ... file--datetouch -t 相同,只是格式更多date --date 喜欢
  • 我想我会删除答案,对吧?或者是否可以在macos 上brew install coreutils 并让gnu 接触macos?
  • --date '01/23/2000 12:00:00.099' file.txt ,这种方式只适用于新创建的文件,但不能更新创建日期和时间..以后只能被更新修改日期时间.. ok ?? Apple 新的 APFS 文件系统可以支持纳秒以及它拥有的更多强大功能!所以当我看到某个地方应该存在如何用纳秒更改或更新文件的生日和时间..
  • 这适用于 macOS 上的 GNU touch(可通过 brew install coreutils 安装)。
猜你喜欢
  • 2022-11-27
  • 1970-01-01
  • 2017-04-18
  • 1970-01-01
  • 1970-01-01
  • 2016-07-07
  • 2016-09-06
  • 2015-12-24
  • 1970-01-01
相关资源
最近更新 更多