[X-Unix] Re: extract CTIME from the commandline?

Xavier Noria fxn at hashref.com
Mon Aug 22 04:39:06 PDT 2005


On Aug 22, 2005, at 6:47, Timothy Luoma wrote:

> I may have my terminology wrong... I'm looking for the created  
> date, the date the file was first made, regardless of when it was  
> last opened or modified.

Yes, ctime means (fom stat(2)):

     Time when file status was last changed (inode data modification).
     Changed by the chmod(2), chown(2), link(2), mknod(2), rename(2),
     unlink(2), utimes(2) and write(2) system calls.

There is a "B" in the man page of stat(1) that means "birth time of  
the inode", but I get a "bad format" error no matter what I try, and  
this message suggests it is not actually built on OS X:

     http://lists.gnu.org/archive/html/bug-coreutils/2004-02/ 
msg00070.html

Looks like the Foundation framework gives access to the creation date  
since 10.2: the class NSFileManager documents a method to get file  
attributes and among them we have

     NSFileCreationDate | NSDate (Available in Mac OS X v10.2 and  
later.)

With the help of people from freenode#macdev I wrote an Objective-C  
program (attached) that prints exactly what you want. To compile it  
(developer tools needed):

     gcc -framework Cocoa -o creation_date creation_date.m

It receives a file as argument name and prints its creation date in  
that format:

     % ./creation_date foo.rb
     2005-07-15

-- fxn

-------------- next part --------------
A non-text attachment was scrubbed...
Name: creation_date.m
Type: application/octet-stream
Size: 938 bytes
Desc: not available
Url : http://listserver.themacintoshguy.com/pipermail/x-unix/attachments/20050822/a1db53bb/creation_date.obj


More information about the X-Unix mailing list