首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在Bash/Debian中获取文件创建日期/时间?

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

Stack Overflow用户
提问于 2013-02-13 05:30:27
回答 9查看 310.8K关注 0票数 85

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

EN

回答 9

Stack Overflow用户

发布于 2013-10-24 22:42:53

代码语言:javascript
复制
ls -i file #output is for me 68551981
debugfs -R 'stat <68551981>' /dev/sda3 # /dev/sda3 is the disk on which the file exists

#results - crtime value
[root@loft9156 ~]# debugfs -R 'stat <68551981>' /dev/sda3
debugfs 1.41.12 (17-May-2010)
Inode: 68551981   Type: regular    Mode:  0644   Flags: 0x80000
Generation: 769802755    Version: 0x00000000:00000001
User:     0   Group:     0   Size: 38973440
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 76128
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x526931d7:1697cce0 -- Thu Oct 24 16:42:31 2013
 atime: 0x52691f4d:7694eda4 -- Thu Oct 24 15:23:25 2013
 mtime: 0x526931d7:1697cce0 -- Thu Oct 24 16:42:31 2013
**crtime: 0x52691f4d:7694eda4 -- Thu Oct 24 15:23:25 2013**
Size of extra inode fields: 28
EXTENTS:
(0-511): 352633728-352634239, (512-1023): 352634368-352634879, (1024-2047): 288392192-288393215, (2048-4095): 355803136-355805183, (4096-6143): 357941248-357943295, (6144
-9514): 357961728-357965098
票数 44
EN

Stack Overflow用户

发布于 2013-03-14 17:10:08

mikyra的回答是good.The事实,就像他说的那样。

代码语言:javascript
复制
[jason@rh5 test]$ stat test.txt
  File: `test.txt'
  Size: 0               Blocks: 8          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 588720      Links: 1
Access: (0664/-rw-rw-r--)  Uid: (  500/   jason)   Gid: (  500/   jason)
Access: 2013-03-14 01:58:12.000000000 -0700
Modify: 2013-03-14 01:58:12.000000000 -0700
Change: 2013-03-14 01:58:12.000000000 -0700

如果要验证文件是首先创建的,可以在创建一系列文件时通过附加系统日期来构造文件名。

票数 25
EN

Stack Overflow用户

发布于 2013-03-14 12:36:28

请注意,如果出于性能原因使用noatime挂载了文件系统,那么atime可能会显示创建时间。鉴于noatime会带来巨大的性能提升(通过在每次读取文件时删除磁盘写操作),它可能是一个明智的配置选项,也可以提供您想要的结果。

票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14842195

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档