Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I find file creation date

Status
Not open for further replies.

gbell

MIS
Feb 19, 2002
86
AU
I know how to check last modified date and date last accessed but I am unable to find the command to show me when a file was created.

The platform is HP-UX 11.11

Thanks in advance
Greg
 
Thanks Vlad,

I was looking for something quick & dirty, a UNIX command. I gather from your response there isn't one.

Regards
Greg
 
There are only three times kept for each file, the last access time, the last modification time, and the last status change time.

If you have a C compiler, try this (I called mine filedates.c)...
Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>

int main(int argc, char ** argv)
{
    struct stat     filestats;

    if ( argc != 2 )
        {
        fprintf(stderr, &quot;filedates: incorrect number of parameters!\n&quot;);
        return( -1 );
        }

    if( stat(argv[1], &filestats) )
        {
        fprintf(stderr, &quot;filedates: Couldn't get file stats for %s!\n&quot;, argv[1]);
        return( -1 );
        }

    printf(&quot;         File Name: %s\n&quot;, argv[1]);
    printf(&quot;              Size: %ld\n&quot;, filestats.st_size);
    printf(&quot;  Last Access Time: %s&quot;, asctime(localtime(&filestats.st_atime)));
    printf(&quot;     Last Mod Time: %s&quot;, asctime(localtime(&filestats.st_mtime)));
    printf(&quot;Last Stat Chg Time: %s&quot;, asctime(localtime(&filestats.st_ctime)));

    return(0);
}
This will give you something like...
[tt]
$ filedates filedates.c
File Name: filedates.c
Size: 1174
Last Access Time: Wed Oct 29 13:44:48 2003
Last Mod Time: Wed Oct 29 13:44:40 2003
Last Stat Chg Time: Wed Oct 29 13:44:40 2003

$ cat filedates.c
[/tt]
Hope this helps.

 
Also ls -l shows the last modified time, ls -lu shows the last accessed time, and ls -lc shows the last status change time.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top