Operating System - HP-UX
1833788 Members
2474 Online
110063 Solutions
New Discussion

Accurate time stamp on files?

 
SOLVED
Go to solution
David Snider
Frequent Advisor

Accurate time stamp on files?

Ok, does anybody know of a simple way of determining the difference in time stamps of creation, modification and accesses on two files including seconds? Tried ls, but it only shows hour and minute differences.. I need to know down to the second information.. I know this information must be available because right clicking on the file from a SAMBA share shows the hour, minute and second of modification, access time and creation time.. But I can't seem to find a way to have a shell script do a right click from my desktop on the file in the share, grab a screen print, OCR the image and dump the text to a file on the unix box.. :-) Thanks in advance..

David..
7 REPLIES 7
Patrick Wallek
Honored Contributor
Solution

Re: Accurate time stamp on files?

Have a look at superls, available here: http://gatekeep.cs.utah.edu/hppd/hpux/Shells/sls-1.0/

This should do what you need to do.
A. Clay Stephenson
Acclaimed Contributor

Re: Accurate time stamp on files?

Hi David:

I have a perl script that I've used for quite a while.

ftimes.pl

ftimes.pl [-m | -a | -c ] [-e] file1 ...

For each file it will print the datestamp of mtime (default) or -a atime or -c ctime. The -e arg causes the output to be in epoch seconds rather than the standard date format.
If more than 1 filename is supplied, the filename is printed followed by the datestamp otherwise simply the datestamp.

Enjoy, Clay
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: Accurate time stamp on files?

Hi David:

Here's a somewhat obtuse way:

# shar -m ./myfile > ./myfile.shar
# grep touch ./myfile.shar

...you will see the modification and access timestamps this way at the hour/minute/second level.

Regards!

...JRF...
Frank Slootweg
Honored Contributor

Re: Accurate time stamp on files?

If you want/must use standard commands and just the modification time will do:

echo /path/file | cpio -o 2>/dev/null | cpio -ivt 2>/dev/null

It is only slightly less obtuse than James' method! :-)

Wodisch
Honored Contributor

Re: Accurate time stamp on files?

Hello,

why not write a small C program to "stat(2)"
that file and use the data you get?

Just my ?0.02,
Wodisch
David Snider
Frequent Advisor

Re: Accurate time stamp on files?

Thanks all for your replies.. Of course the simple click here and download this file c/o patrick was my favorite, I did try the others, James, for some reason, that shar -m alwasy shows the seconds as 01, no matter how often I change the file.. And sorry Frank, I couldn't get yours to work at all.. Echo /path/file would do just that, just echo the text '/path/file' to the screen..

Thanks again for all of your replies.. ;-)
James R. Ferguson
Acclaimed Contributor

Re: Accurate time stamp on files?

Hi (again) David:

My apologies! I could have sworn that I was correct. It turns out that the "01" you see is the YY (year). If you look at the 'touch' man pages, you will see that the syntax used in the 'shar' file is the deprecated form of 'touch' where the timestamp is expressed as 'MMDDhhmm[YY]' instead of '[[CC]YY]MMDDhhmm[.SS]'.

Regards!

...JRF...