How to get file creation date/time in Bash/Debian? How to get file creation date/time in Bash/Debian? linux linux

How to get file creation date/time in Bash/Debian?


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)

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

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


ls -i file #output is for me 68551981debugfs -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/sda3debugfs 1.41.12 (17-May-2010)Inode: 68551981   Type: regular    Mode:  0644   Flags: 0x80000Generation: 769802755    Version: 0x00000000:00000001User:     0   Group:     0   Size: 38973440File ACL: 0    Directory ACL: 0Links: 1   Blockcount: 76128Fragment:  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: 28EXTENTS:(0-511): 352633728-352634239, (512-1023): 352634368-352634879, (1024-2047): 288392192-288393215, (2048-4095): 355803136-355805183, (4096-6143): 357941248-357943295, (6144-9514): 357961728-357965098


mikyra's answer is good.The fact just like what he said.

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

if you want to verify wich file was created first,you can structure your file name by appending system date when you create a series of files.