1 Sep 2004 01:44
RE: [U2] [Unix] creation date/time
ken_wallis <at> internode.on.net <ken_wallis <at> internode.on.net>
2004-08-31 23:44:20 GMT
2004-08-31 23:44:20 GMT
Karl L Pearson wrote:
> The question was: Creation date and time, not last
accessed date and
> time.
> On Mon, 2004-08-30 at 18:56, 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
st_ctime is the date/time the inode last changed. This is
equivalent to ls -lc except as Ian says, if it happened more
than a year ago, ls reports just the date, not the time. As
(Continue reading)
RSS Feed