I'm using Bash on Debian GNU/Linux 6.0. Is it possible to get the file creation date/time? Not the modification date/time.
ls -lh a.txt
and stat -c %y a.txt
both only give the modification time.
相关问题
- How to get the return code of a shell script in lu
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- JQ: Select when attribute value exists in a bash a
- Invoking Mirth Connect CLI with Powershell script
You can find creation time - aka birth time - using stat and also match using find.
We have these files showing last modified time:
To find files created within a certain time frame using find as below.
Clearly, the filesystem knows about the birth time of a file:
We can confirm this using stat:
stat man pages explains %w:
mikyra's answer is good.The fact just like what he said.
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.
Creation date/time is normally not stored. So no, you can't.
Note that if you've got your filesystem mounted with noatime for performance reasons, then the atime will likely show the creation time. Given that noatime results in a massive performance boost (by removing a disk write for every time a file is read), it may be a sensible configuration option that also gives you the results you want.
ls -i menus.xml
94490 menus.xml Here the number 94490 represents inode
Then do a:
df -h
To find the mounting point of the root "/" filesystem, because the file menus.xml is on '/' that is '/dev/mapper/vg-root'
debugfs -R 'stat <94490>' /dev/mapper/vg-root
The output may be like the one below:
debugfs -R 'stat <94490>' /dev/mapper/vg-root
Where you can see the creation time:
Cited from https://unix.stackexchange.com/questions/50177/birth-is-empty-on-ext4/131347#131347 , the following shellscript would work to get creation time: