I want to find a file which I created recently, but I don't remember anything and can only guess it is under a directory indirectly with any possible depth. I inspected the times of all the subdirectories of a directory, buttheir times are all older than the time I created the file. I wonderwhy a dir's time isn't updated when a file in it is?If it were you, how would you find the file? By using find andsome option for time? Thanks.
Does change of a file in a directory not change the time of the directory?
find;directory;timestamps
The modification time of a directory, like any other file (note how directories are called directories (a list of name/number mappings like a phone directory) and not folders) is updated whenever the content is modified.That is when a file is added (linked), removed (unlinked), or renamed in it.Beware that files can be linked to several directories. The system doesn't maintain a live list of which directory any file is linked to (for a given open file descriptor for writing, it doesn't even keep track of which path was used to open the file (the components of which can be renamed at any moment anyway)), and if it were and if it were to update the modification time of every directory the file is linked to along with all their ancestors back to /, it would end up doing only that.Generally, your only option is to look for the modification time of every file on the file system.You can use find as shown by Corentin, or to avoid having to read all those directories, you can look at the modification times of all the inodes in the inode table (though I'm not aware of any tool that does that).Some file systems, like btrfs can give you some clue as to what the most recently modified files were:$ sudo btrfs sub find-new / -1transid marker was 2273028$ sudo btrfs sub find-new / 2273020inode 60319801 file offset 212992 len 4096 disk start 8350875648 offset 0 gen 2273024 flags NONE root/screenlog.2inode 60319801 file offset 217088 len 28672 disk start 8403632128 offset 0 gen 2273023 flags NONE root/screenlog.2inode 61045822 file offset 360448 len 4096 disk start 1111568384 offset 0 gen 2273022 flags NONE var/log/apache2/access.loginode 61045835 file offset 2326528 len 8192 disk start 7824994304 offset 0 gen 2273024 flags NONE var/log/sysloginode 61045840 file offset 57344 len 8192 disk start 1517305856 offset 0 gen 2273023 flags NONE var/log/kern.log[...] 