Get file created/creation time?
How do I do a ls and then sort the results by date created?
Is there a command in Linux which displays when the file was created ? I see that
ls -lgives the last modified time, but can I get the created time/date?
Even while "OT" as this is asking for a tool to display this information, I think it's a valuable thing for programmers to know when dealing with more UNIX-y filesystems.
The command is `sudo debugfs -R 'stat /path/to/file' /dev/sdaX` (replace `sdaX` with the device name of the filesystem on which the file resides). The creation time is the value of `crtime`. You can add `| grep .[^ca]time` to list just `mtime` (the modification time) and `crtime` (the creation time).
statcommand may output this
-(dash). I guess it depends on the filesystem you are using.
statcalls it the "Birth time". On my
ext4fs it is empty, though.
%wTime of file birth, human-readable; - if unknown
%WTime of file birth, seconds since Epoch; 0 if unknown
stat foo.txt File: `foo.txt' Size: 239 Blocks: 8 IO Block: 4096 regular file Device: 900h/2304d Inode: 121037111 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ adrian) Gid: ( 100/ users) Access: 2011-10-26 13:57:15.000000000 -0600 Modify: 2011-10-26 13:57:15.000000000 -0600 Change: 2011-10-26 13:57:15.000000000 -0600 Birth: -
What if we do not have the `stat` command installed and I cannot add the `stat` command to this environment? `bash: stat: command not found`
While you mention %w you don't say how to use it. I'd suggest modifying this answer to show an example command to get the creation date if it's not included by default. For example "stat -c %w file"
Linux offers three timestamps for files: time of last access of contents (atime), time of last modification of contents (mtime), and time of last modification of the inode (metadata, ctime). So, no, you cannot. The directory's mtime corresponds to the last file creation or deletion that happened, though.
The file creation time is actually stored in Ext4, but not directly accessible. See http://unix.stackexchange.com/a/50184/8250
No, there is no such a command. In Unix creation time is not stored (only: access, modification and change).
Not true in general. Some common filesystems used in Linux don't store creation time, but others do: see http://unix.stackexchange.com/questions/7562/what-file-systems-on-linux-store-the-creation-time
Some files may have metadata (such as exif) which record the creation date/time. If all of your files happen to be digital photos, you most likely have this data. Here is an example using perl's Image::ExifTool.