命令行管理程序:显示最早创建的文件 DATE 及其路径



macOS Majove

我可以在目录中找到最旧的已创建文件:

cd /path/ && ls | xargs mdls -name kMDItemContentCreationDate | awk '{print $3, $4}' | sort -n | head -n1

输出:

2020-02-04 08:24:46

但我很难让它的路径一起显示出来。我想要这样的东西:

2020-02-04 08:24:46 /Path/Filename

我可以轻松地用last access time做到这一点,但在创作时间方面就不行了。任何帮助将不胜感激。很确定这是一件简单的事情,我只是想多了:(

使用while循环而不是xargs。然后,您可以打印文件名以及元数据。

cd /path/ && ls | while read f; do
printf '%s %s %sn' $(mdls -name kMDItemContentCreationDate "$f" | awk '{print $3, $4}') "$f"
done | sort -n | head -n1

相关内容

最新更新