"ls -lc" is ok, but you're going to have to do some parsing of the results
for it to make sense.  On linux you can do 

ls -lc --time-format=long-iso

which makes the format somewhat more consistent, but on other systems the
date/time format varies a little depending on if ctime is in the current
year.

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] 
> Sent: Monday, August 30, 2004 7:35 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [U2] [Unix] creation date/time
> 
> 
> Ian McGowan wrote:
> 
> > If your system doesn't have the stat or fstat command,
> this
> > small program may do:
> > 
> > #include <sys/stat.h>
> > main(int argc,char**argv) {
> >     struct stat buf;
> >     char d[256];
> >     stat(argv[1],&buf);
> >     strftime(d, sizeof(d), "%D",
> localtime(&buf.st_ctime));    
> > printf("%s\n", d); }
> > 
> > (error checking removed)
> > 
> > Or a perl one-liner:-)
> > 
> > perl -e 'print scalar localtime((stat $ARGV[0])[9]),"\n"'
> $filename
> 
> Or, to get the same result, try:
> 
> ls -lc $filename
> 
> Sadly, this won't necessarily do what the OP wanted.  The 
> st_ctime element of the stat structure contains the time that 
> the inode was last changed, while the st_mtime element 
> contains the time the file itself was modified.
> 
> The time the inode was modified *MAY* be the time when the
> file was created, but it may well not be.  For example, if 
> someone has chown'ed the file, or chmod'ed it, then the 
> st_ctime element will reflect the time that happened, and the 
> creation time will have been lost.
> 
> I do not believe that there is any way to ascertain the 
> creation date of a UNIX file with certainty.
> 
> Cheers,
> 
> Ken
> 
> >> -----Original Message-----
> >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> 
> >> I am looking for a unix command that could return the
> date
> >> and time that a file was created.  Anybody out there now
> of such an
> >> animal?
> -------
> u2-users mailing list
> [EMAIL PROTECTED]
> To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to