Command to get File Timestamp including seconds [Aix 5.3]

Is there a command (like ls -l) to get the file time stamp including seconds? The ls -l gives only the HH:MM, No SS

I don't have a C compiler to call stat()
I don't a command like stat too.

Please help.

As far as I know only GNU ls supports this

$ ls -l
total 488
-rw-r--r--  1 me mygroup 234329 Aug  7 22:58 curl-7.15.5-2.el5.x86_64.rpm
-rw-r--r--  1 me mygroup 253488 Aug  7 23:10 curl-7.16.4-1.fc8.x86_64.rpm
$ ls -l --full-time
total 488
-rw-r--r--  1 me mygroup 234329 2007-08-07 22:58:11.000000000 -0400 curl-7.15.5-2.el5.x86_64.rpm
-rw-r--r--  1 me mygroup 253488 2007-08-07 23:10:56.000000000 -0400 curl-7.16.4-1.fc8.x86_64.rpm

Cheers
ZB

I suppose, that is the precision in which the details are stored in the inode.

Even when you do a stat, HH : MM is the precision limit you get

Access: 2007-05-12 01:54:00.000000000
Modify: 2007-05-12 01:54:00.000000000
Change: 2007-05-12 01:54:00.000000000

Somebody might be knowing about this in detail :slight_smile:

ls -l --full-time is not working however. Is the precision configurable? I mean somewhere in the /etc ?

a perl one-liner:

$ touch file.now
$ perl -e '@d=localtime ((stat(shift))[9]); printf "%02d-%02d-%04d %02d:%02d:%02d\n", $d[3],$d[4]+1,$d[5]+1900,$d[2],$d[1],$d[0]' file.now
08-08-2007 10:20:36
$

That perl one liner (below) works perfectly. Can someone please explain what it is actually doing? I actually need the timestamp in this format:
yyyymmddhhmmss

perl -e '@d=localtime ((stat(shift))[9]); printf "%02d-%02d-%04d %02d:%02d:%02d\n", $d[3],$d[4]+1,$d[5]+1900,$d[2],$d[1],$d[0]' file.now 08-08-2007 10:20:36

I don't understand the significance of "08-08-2007 10:20:36" after the filename?

For informational purpose for AIX users

istat <filename>

returns following result

Inode 1784 on device 10/4       File
Protection: rw-r--r--
Owner: 0(root)          Group: 0(system)
Link count:   1         Length 7240 bytes

Last updated:   Thu Mar  6 18:49:23 IST 2008
Last modified:  Thu Mar  6 18:49:23 IST 2008
Last accessed:  Thu Mar  6 18:18:19 IST 2008

Formatting is a bit tough though than the perl solution, I think.

I also want to know the significance of "file.now 08-08-2007 10:20:36" in the perl script.. could u pls explain

hey.. i got it.. that is the output of that cmd.. :P.. but hw can we get it assigned to a variable???