2

According to How to find creation date of file?, in Linux filesystems, such as ext4, Btrfs and JFS, that store the file creation time (aka birth time), it is possible to display the file birth time (in human-readable format) with the following command

stat -c '%w' approved-images.txt
2019-12-04 16:50:21.539553500 +0000

(Note that on Linux this requires coreutils 8.31, glibc 2.28 and kernel version 4.11 or newer.)

But the POSIX standard only defines three distinct timestamps to be stored for each file: the time of last data access, the time of last data modification, and the time the file status last changed.

Also in the POSIX standard of find, there is no mention of the creation date of files.

For filesystems that store the creation date, is there a way of finding files whose birth date is after a given timestamp in a way that works in bash, dash and zsh shells??

Edit: As commented by JdeBP, in Is there really no way in Linux to get creation time for files on cifs/smb share? and Is there still no Linux kernel interface to get file creation date? there already have been extensive discussions related with this question.

And, as commented by Stéphane Chazelas, in Remove all files created before a certain date is stated that some BSDs have find -newerBt to check the file's inode birth time.

8
  • 2
    I think you might need to define "portable" here. Do you mean "portable to any system that can handle one of these file systems", so any *nix machine, or do you mean "portable across Linux distributions"?
    – terdon
    Jan 30, 2020 at 12:07
  • @terdon Updated the question. Jan 30, 2020 at 12:12
  • 1
    Thanks, but you didn't answer the question: is this about portability to any *nix or only across Linux? Since you mention coreutils, and kernel versions, for instance, which are a Linux thing. So even if you just want Linux, that will still be limited to those systems with the right versions, which would make it non-portable again. So please define the scope of the question more clearly.
    – terdon
    Jan 30, 2020 at 12:23
  • POSIX has no birthdate and birthdane is a BSD invention. While BSD has it in struct stat, Solaris ZFS has it (under the name crtime) in the extended attributes and as a result the way to retrieve this value is totally platform dependent.
    – schily
    Jan 30, 2020 at 12:45
  • 1
    superuser.com/a/703927/38062 and unix.stackexchange.com/q/304779/5132 are also related.
    – JdeBP
    Jan 30, 2020 at 13:16

0

You must log in to answer this question.

Browse other questions tagged .