【问题标题】:Are there any commands showing Apple File System (APFS) timestamps in nanoseconds?是否有任何命令以纳秒为单位显示 Apple 文件系统 (APFS) 时间戳?
【发布时间】:2018-03-20 05:47:18
【问题描述】:

我听说timestamps in APFS are in nanoseconds。

是否有任何命令能够以纳秒为单位显示 APFS 时间戳?

我已经尝试过ls、stat,但到目前为止还没有运气。

【问题讨论】:

  • 你试试这个:echo $(($(date +%s%N)/1000000)) 在你的终端运行这个命令
  • @YaseenAhmad 运行您的命令会导致此错误:bash: 1508845153N: value too great for base (error token is "1508845153N")。我想知道的不是当前时间,而是文件的时间戳。

标签: macos command-line filesystems macos-high-sierra apfs


【解决方案1】:

没有命令,但你可以创建一个简单的 C 程序来测试它:

#include <stdio.h>
#include <sys/stat.h>

int main() {
    struct stat attr;
    stat("/path/to/file", &attr);
    printf("Last modified time: %ld", (long)attr.st_mtimespec.tv_nsec);
}

【讨论】:

  • 这应该是(long)attr.st_mtimespec.tv_nsec - 打印值的地址没有意义......
【解决方案2】:

您可以通过请求浮点输出获得纳秒时间戳:

% stat -f %Fm foo
1609297230.485880489

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-01
    • 2018-03-07
    • 2011-07-08
    • 1970-01-01
    相关资源
    最近更新 更多