Thanks Ken and Ian.  I find that I am constantly using the ls command and then parsing 
the results.  Just wondered if there was a better way.

-------------- Original message -------------- 

> Ian McGowan wrote: 
> 
> > If your system doesn't have the stat or fstat command, 
> this 
> > small program may do: 
> > 
> > #include 
> > 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