Does this depend on the OS or the filesystem? In FreeBSD, you can actually get at this from stat , in Linux the syscall has not been reworked so you have to resort to hacking with debugfs. First example echo command which gives file age in seconds worked, but the other variant third echo command didn't work for me under Ubuntu 20 in a Bash shell script. The only information that's available is typically the last times the files was: Accessed Modified Changed Access - the last time the file was read Modify - the last time the file was modified content has been modified Change - the last time meta data of the file was changed e.
Filesystems If you're ever curious take a look at this Wikipedia topic titled: Comparison of file systems. References How to find creation date of file? How do I do a ls and then sort the results by date created? Why does Unix time start at ? Thanks for the update, that helps. Actually, I read here that ext4 can keep creation dates but this has not been implemented in the kernel yet.
It seems long overdue to me, I understand in the past why it was left out, but everything has advanced so much since the beginning that it doesn't make sense to explicitly not have this.
Also you can disable the support for access time so it could be implemented similarly and then disabled if you really didn't want it. Add a comment. Based on answer by Gilles, here is a bash function that returns file age in seconds or error.
HalosGhost 4, 10 10 gold badges 30 30 silver badges 40 40 bronze badges. Nicholas Sushkin Nicholas Sushkin 2 2 silver badges 3 3 bronze badges. Neat function , easy to adapt by adding simple division to see age in Hour, Days, week Hauke Laging Guido Rizzi Guido Rizzi 21 1 1 bronze badge. Microsoft Default Browser Firefox. Google's New Pet Art. Robinhood Hack Find Downloaded Files on an iPhone. Use Your iPhone as a Webcam. Hide Private Photos on iPhone. Take Screenshot by Tapping Back of iPhone.
Should You Upgrade to Windows 11? Browse All Windows Articles. Copy and Paste Between Android and Windows. Protect Windows 10 From Internet Explorer. Mozilla Fights Double Standard. Connect to a Hidden Wi-Fi Network.
Change the Size of the Touch Keyboard. Check Bluetooth Device Battery Life. Reader Favorites Take Screenshot on Windows. Mount an ISO image in Windows. Several answers are possible here and no consensus exists. Mentioning the ctime is nice, though, but I wouldn't put it semantically near the vague concept of a "creation time".
Especially since a simple chmod , applied on the file, will nullify that idea. But I can live with you doing that ;- — Alfe.
Actually it's better to use access time which is a creation time on all file systems mounted with noatime option which is good for performance so you should use it. Vide Vide 81 1 1 silver badge 1 1 bronze badge.
Examples of when both fields get updated: "Modify" will be updated if someone concatenated extra information to the end of the file.
But it will be quite tedious to parse in order to get what we want. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Explaining the semiconductor shortage, and how it might end. Does ES6 make JavaScript frameworks obsolete? Featured on Meta. Now live: A fully responsive profile. Linked Related Delete files older than "x" if directory size is greater than "y".
I wrote a script to delete files which are older than "x" days, if the size of the directory is greater than "y"! Script for delete tmp files older than 15 days and owned by "xxx" id.
But, i need a script to IF Condition in ". Hi, I have the below ". Please see the remarks in the code below:! RedHat Commands. OpenSolaris Commands. Linux Commands. SunOS Commands. FreeBSD Commands. Full Man Repository.
0コメント