有没有办法知道ubuntu中文件的创建时间?
我正在使用 ubuntu 并且想知道文件的创建时间,即使它被修改或访问?
i am using ubuntu and want to know the creation time of a file even when it gets modified or accessed ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
不幸的是,Unix 不存储文件的创建时间。
您可以使用 stat 是
注意: 当使用文件系统类型 ext4 crtime 可用!
Unfortunately Unix does not store the creation time of a file.
All you are able to get using stat is
Note: When using filesystem type ext4 crtime is available!
这个小脚本可以获取 ext4 的创建日期:
我将其命名为
fcrtime
并将其放在我的~/bin
文件夹中。因此,在任何文件夹中,我都可以使用以下命令:
fcrtime example.odp
示例输出:
crtime: 0x5163e3f0:12d6c108 -- Tue Apr 9 12:48:32 2013
相比统计同一文件:
注释
realpath
。在Ubuntu例如。使用sudo apt-get install realpath
安装它,/dev/sda4
替换为从mount|grep ext4
获得的内容This little script can get the creation date for ext4:
I named it
fcrtime
and put it in my~/bin
folder.So in any folder I can use the command like:
fcrtime example.odp
Example output:
crtime: 0x5163e3f0:12d6c108 -- Tue Apr 9 12:48:32 2013
Compared to stat-ing the same file:
NOTES
realpath
is usually not installed by default. In Ubuntu eg. install it withsudo apt-get install realpath
/dev/sda4
if necessary with the one you get frommount|grep ext4
最接近的可用属性是“更改时间”,也称为
ctime
。这是针对各种系统调用进行更新的,任何修改 inode 的调用,而不是它包含的数据。链接
The closest attribute available is the "change time", also known as
ctime
. This is updated for various system calls, any that modify the inode, rather than the data it contains.Links
根据 http://en.wikipedia.org/wiki/Comparison_of_file_systems,这适用于 ext4 、btfrs、FAT、NTFS 和 UDF 文件系统,以及其他一些您不太可能遇到的文件系统。它不适用于 ext2 或 ext3,这可能是 Ubuntu 中最常见的文件系统格式。
不过,您需要内核补丁:http://lwn.net/Articles/394391/ 。显然这是因为 Linus 拒绝了创建时间属性,理由是有人称它为“otime”而其他人称它为“btime”,因此这个想法肯定是无用的。
According to http://en.wikipedia.org/wiki/Comparison_of_file_systems, this is available for ext4, btfrs, FAT, NTFS, and UDF filesystems, plus some others you're unlikely to encounter. It's not available on ext2 or ext3, probably the most common file system formats in Ubuntu.
You'll need a kernel patch, though: http://lwn.net/Articles/394391/. Apparently this is because Linus rejected creation time attribute on the grounds that somebody called it an "otime" and somebody else called it a "btime", and therefore the idea must be useless.
创建时间被称为文件出生时间,并且在某些文件系统上受支持,仅某些内核。命令将是 Mohsen Pahlavanzadeh 答案:
注意:此问题与 如何查找文件的创建日期?。另外,请务必阅读此问题Linux 上的哪些文件系统存储创建时间?。
Creation time, is known as file Birth time and is supported on some filesystem, with some kernels only. The command would be Mohsen Pahlevanzadeh answer:
Note: this question is a duplicate of How to find creation date of file?. Also, make sure to read this question What file systems on Linux store the creation time?.
是的 - stat(): http://manpages.ubuntu.com/manpages /hardy/man2/stat.2.html
Yup - stat(): http://manpages.ubuntu.com/manpages/hardy/man2/stat.2.html
伙计们,我刚刚写完这个脚本,这个脚本是使用 perl 查找文件的创建日期:
guys i just finished writing this script this script to find the creation date of a file using perl: