Operating System - HP-UX
1833914 Members
2226 Online
110063 Solutions
New Discussion

Listing Files with Date and Time

 

Listing Files with Date and Time

I'm hoping someone here can help me. I've got a user who's trying to list files in a directory but he requires the output to include a file's eight digit create date and 4-6 digit time stamp. Is this possible? I could not find any command which returned this information. Any guidance you could give me would be greatly appreciated.

Thank You In Advance,
Sincerely and Respectfully,
Pamela Goodwin
UNIX Systems Admin
"...it's turtles all the way down."
3 REPLIES 3
Dan Hetzel
Honored Contributor

Re: Listing Files with Date and Time

Hi Pamela,

Unfortunately, the file creation date isn't kept in the inode. The only dates that you can retrieve are:
modification date
status change date
last accessed date

At the time of file creation, the modification date will correspond with the cration date but, as soon as file is modified, the modification date will change and creation date will be lost.

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
CHRIS_ANORUO
Honored Contributor

Re: Listing Files with Date and Time

Hello Pam,

I agree with Dan, use ls -lrt|pg this will sort and list the files with the most recent modified last.
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Wodisch
Honored Contributor

Re: Listing Files with Date and Time

Hello Pamela,
as long as no "change" command has been issued to
those files, the "ctime" (change time) still shows the
time of creation! Use "ls -lc" to see it.
But for your format, I am afraid, you have to use
"pstat" and a C-program, or PERL (the "Camelbook"
shows an example with those dates, if I remember
right).
HTH,
Wodisch