UNIX脚本 - 查找文件 - 显示日期

时间:2013-02-22 09:59:43

标签: shell unix scripting find

我正在运行以下命令:

find . -atime -30

但是在输出中,我希望它显示访问时间的时间戳。还希望它尽可能显示访问该文件的用户。

你能帮忙吗?

感谢。

3 个答案:

答案 0 :(得分:4)

使用printf的{​​{1}}选项:

find

请查看man find以了解不同的find . -atime -30 -printf '%u %Ac %p\n' 格式选项。

答案 1 :(得分:2)

find . -atime -30 -print0 | xargs -0 ls -lud

您无法确定访问该文件的人员,通常不会记录此信息。

请记住,atime并不总是更新(取决于文件系统挂载选项)。

如果要将查找限制为仅文件,则可以执行以下操作:

find . -atime -30 -a -type f -print0 | xargs -0 ls -lud

答案 2 :(得分:1)

上次访问不会记录访问该文件的用户。

find . -atime -30 -exec stat {} +

将为您提供所有可以获得的信息。

如果您没有GNU查找或统计信息,请尝试Petesh建议的内容。