| New Reply |
List file creation date in bash |
Share Thread | Thread Tools |
| Nov12-12, 09:19 PM | #1 |
|
Recognitions:
|
List file creation date in bash
How do you list creation date of a file in linux bash? I want to find creation date of some files, not just modification date. Thanks.
|
| Nov12-12, 09:36 PM | #2 |
|
Mentor
|
According to 'man ls' on Mac OS, 'ls -Ul' shows the file-creation time instead of the last-modification time, in the long-format output.
|
| Nov12-12, 09:54 PM | #3 |
|
Recognitions:
|
That does not appear to work on GNU bash; i.e., "ls -Ul" does not appear to give file creation date on GNU bash (redhat linux). Any other ideas?
|
| Nov12-12, 09:57 PM | #4 |
|
|
List file creation date in bash
It depends on the file system. Traditionally UNIX file systems like ffs, ufs, and ext2 only kept mtime, ctime and atime: mtime == modifocation time, ctime == inode change time, and atime == access time.
Some newer filesystems have file creation times: ufs2 → st_birthtime zfs → crtime ext4 → crtime btrfs → otime jfs → di_otime Code:
stat -c %W filename stat -c %w filename If your ls man page does not show an option then you are stuck with stat, which had crtime support earlier. This is not an "idea" - this is how the thing works. Check Code:
mount -p Code:
/etc/mnttab |
| Nov12-12, 10:14 PM | #5 |
|
Recognitions:
|
The mount command appears to say the file system is "ext3 (rw,nodev)." My stat command does not have a %W nor %w option. If I issue only the command "stat filename," it lists the following. What should I try now?
Access: <date/time> |
| Nov12-12, 10:52 PM | #6 |
|
|
Um. the polite term is you are out of luck.
An answer that is constructive but probably NOT what you want to hear: 1 download the package, rpm or whatever your linux calls it, for ext4 support. 2. install ext4. 3. mount the ext4 filesystem. Follow the guidelines for enabling crtime support. 4. All files written onto the new filesystem will then have creation dates. Next. 1. download and install the very latest coreutils for your linux. Your commands now support creation times. Don't do all that unless you are really masochistic. Without using the word creation date (or time) please tell me what you are actually trying to do. Where there is a shell there is a way. |
| Nov12-12, 11:15 PM | #7 |
|
Recognitions:
|
I am not that masochistic.
![]() Because I want to know when some content was initially created, I do not know how to explain it without using some of the words in post 1. Anyway, thank you very much for the help. |
| Nov12-12, 11:29 PM | #8 |
|
|
ctime will do for most of what creation time does.
Unless you use these commands a lot: chmod, chown, setfacl ctime is completely identical to creation time as kept by windows. Code:
cd /path/to/content ls -ltc *.whatever # files in order most recent -> oldest and shows ctime ls -ltrc *.something # files in order oldest -> most recent and shows ctime |
| Nov12-12, 11:53 PM | #9 |
|
Recognitions:
|
No, "ls -ltc" shows, e.g., "2012-11-04" on almost all of my files, or a large percentage of them, even though I did not change anything in or about those files in that time frame. Therefore, that command is not working for giving me any indication of file creation date. But thanks again for all the information.
|
| Nov13-12, 06:09 AM | #10 |
|
|
Quick question...
forget about GNU bash for a moment...can you get creation time for your files any other way? just trying to figure out if it is even being preserved by your OS or available with your FS can you see creation time using the file manager? (nautilus? or whatever?) if it is available, then, I am sure there is a way to retrieve it...in the worst case, you may need to figure out what the file manager is doing to get it. any way, just checking, just a thought |
| Nov13-12, 05:10 PM | #11 |
Recognitions:
|
ctime MIGHT be the time when the file was first created, but there is no guarantee, and no way to find out if it is or isn't AFAIK. |
| New Reply |
| Thread Tools | |
Similar Threads for: List file creation date in bash
|
||||
| Thread | Forum | Replies | ||
| [BASH] How to change from reading from a file to reading from STDIN in while loop? | Programming & Comp Sci | 2 | ||
| Suggestion List current date and time | Forum Feedback & Announcements | 18 | ||
| Print last entered date from .txt file | Engineering, Comp Sci, & Technology Homework | 5 | ||
| Bash: Including a path from one file into another | Programming & Comp Sci | 4 | ||
| Bash script - Monitor File Writes? | Programming & Comp Sci | 9 | ||