linux - 如何在 Bash/Debian 中获取文件创建日期/时间?

标签 linux bash shell debian ls

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

最佳答案

不幸的是,您的任务通常是不可能的,因为按照 POSIX 标准的定义,您的每个文件只存储了 3 个不同的时间值(参见 Base Definitions section 4.8 File Times Update)

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>.

编辑:正如下面评论中提到的,根据使用的文件系统,元数据可能包含文件创建日期。但是请注意,此类信息的存储是非标准的。取决于它可能会导致迁移到另一个文件系统的可移植性问题,以防实际使用的文件系统以某种方式存储它。

关于linux - 如何在 Bash/Debian 中获取文件创建日期/时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14842195/

相关文章:

python - 在RobotFramework中,我们如何将一个测试套件的值(value)运用到Linux中的另一个测试套件中?

python - Mayavi (Python 3.X) Linux 的替代品

c - Bash 将脚本参数插入字符串

linux - sed 删除行(模式匹配)在我的情况下不起作用

linux - 递归地从相同的文件夹克隆权限

linux - 在 Bash 中导入远程源文件

php - cURL 命令行登录 (bash)

ruby - 双叉和标准输入

linux - 多文件 View ,如数据库 View

bash - bash脚本中的 echo 制表符