On Unix, is there a command to display a file's modification time, precise to the second?
On Linux this is easily done with a "stat -c %y", which returns something like 2009-11-27 11:36:06.000000000 +0100
. I found no equivalent on Unix.
On Unix, is there a command to display a file's modification time, precise to the second?
On Linux this is easily done with a "stat -c %y", which returns something like 2009-11-27 11:36:06.000000000 +0100
. I found no equivalent on Unix.
According to the man page on my Mac (which has the BSD standard version of stat) you can get the epoch time version of the modification in seconds with:
Or if you want to print that out in hours:mins:secs you can do this:
Seconds:
Or, with more precision (up to nanosecond precision), if your filesystem supports it:
Today I encountered the same issue on an old version of HP-UX. The stat program was not part of the installation. (just the C version)
The quickest solution for me was to use a tool such as Tectia file transfer running on my laptop, without actually doing any copying, It converts the time of last modification for you from HP-UX and provides dates and times for all files once you have logged into UNIX.
Possibly this works with other similar graphic based file transfer tools, but I have not tried yet.
For anyone facing the same issue, I found no solution (on HP-UX 11i anyway). Ended up coding a personalized "ls -lh" for my needs. It's not that hard.. Prints something like :
Here it is :
In printFSObjectInfo() you have full functionality of lstat() system call, you can customize this to your wishes.
Be well.
On Mac OS X (tested on 10.10.5 Yosemite thru 10.12.4 Sierra):
The following gives you last modified time in seconds since Epoch: