如何在 Bash/Debian 中获取文件创建日期/时间? [英] How to get file creation date/time in Bash/Debian?

查看:59
本文介绍了如何在 Bash/Debian 中获取文件创建日期/时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Debian GNU/Linux 6.0 上使用 Bash.是否可以获取文件创建日期/时间?不是修改日期/时间.ls -lh a.txtstat -c %y a.txt 都只给出修改时间.

I'm using Bash on Debian GNU/Linux 6.0. Is it possible to get the file creation date/time? Not the modification date/time. ls -lh a.txt and stat -c %y a.txt both only give the modification time.

推荐答案

不幸的是,您的任务通常无法实现,因为 POSIX 标准定义的每个文件只存储了 3 个不同的时间值(请参阅基本定义部分 4.8 文件时间更新)

Unfortunately your quest won't be possible in general, as there are only 3 distinct time values stored for each of your files as defined by the POSIX standard (see Base Definitions section 4.8 File Times Update)

每个文件都有三个不同的相关时间戳:上次的时间数据访问、上次修改数据的时间和文件的时间状态最后更改.这些值在文件中返回特征结构 struct stat,如 中所述;.

Each file has three distinct associated timestamps: the time of last data access, the time of last data modification, and the time the file status last changed. These values are returned in the file characteristics structure struct stat, as described in <sys/stat.h>.

如以下评论中所述,根据所使用的文件系统,元数据可能包含文件创建日期.但是请注意,此类信息的存储是非标准的.依赖于它可能会导致移动到另一个文件系统的可移植性问题,以防实际使用的那个以某种方式存储它.

As mentioned in the comments below, depending on the filesystem used metadata may contain file creation date. Note however storage of information like that is non standard. Depending on it may lead to portability problems moving to another filesystem, in case the one actually used somehow stores it anyways.

这篇关于如何在 Bash/Debian 中获取文件创建日期/时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆