Command to get File Timestamp including seconds [Aix 5.3]


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Command to get File Timestamp including seconds [Aix 5.3]
# 1  
Old 08-08-2007
Data 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.
# 2  
Old 08-08-2007
As far as I know only GNU ls supports this
Code:
$ 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
# 3  
Old 08-08-2007
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

Code:
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 Smilie
# 4  
Old 08-08-2007
ls -l --full-time is not working however. Is the precision configurable? I mean somewhere in the /etc ?
# 5  
Old 08-08-2007
a perl one-liner:
Code:
$ 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
$

# 6  
Old 04-25-2009
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?
# 7  
Old 04-27-2009
For informational purpose for AIX users

Code:
istat <filename>

returns following result

Code:
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need help with UNIX command to get the latest file from list of files with timestamp

Hi All, I have list of files like below with name abcxyz.timestamp. I need a unix command to pick the latest file from the list of below files. Here in this case the lates file is abcxyz.20190304103200. I have used this unix command "ls abcxyz*|tail -1" but i heard that it is not the appropriate... (2 Replies)
Discussion started by: rakeshp
2 Replies

2. Shell Programming and Scripting

Time in seconds on AIX 4.3.2.0

Hi to everybody again i Need your help, i wasting hours but can't find a solutuin for my Problem. I am not an expert with AIX script programming. I have a csh script and i need the time in seconds but since i have an old AIX the Option -%s doesnot exist with the date command. I seach in Google... (13 Replies)
Discussion started by: Nadielosabra
13 Replies

3. AIX

Getting files through find command and listing file modification time upto seconds

I have to list the files of particular directory using file filter like find -name abc* something and if multiple file exist I also want time of each file up to seconds. Currently we are getting time up to minutes in AIX is there any way I can get file last modification time up to seconds. (4 Replies)
Discussion started by: Nitesh sahu
4 Replies

4. Shell Programming and Scripting

AIX : Need to convert UNIX Timestamp to normal timestamp

Hello , I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies

5. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

6. Shell Programming and Scripting

Need file timestamp without stat command

Hi all, I want to check whether a file is not updated in last 15 minutes, for this i need to get timestamp of file, (yyyy:mm:dd:hh:mi:ss). I dont have access to STAT command :(. Please suggest a program or command to do this . Thanks, Saravana (1 Reply)
Discussion started by: sam_1210
1 Replies

7. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

Hi All, I am new to unix programming. I am trying for a requirement and the requirement goes like this..... I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies

8. AIX

AIX TL updates not including all packages needed

In trying to resolve my issue, I downloaded TL 11 and trying to update to it. Why the heck does not the TL fix have the required files in it? Thats another 1.+ GB download. I am also sure that when I go to install that package it will complain about rsct not being updated. MISSING... (1 Reply)
Discussion started by: mrmurdock
1 Replies

9. AIX

Unable to display the date-time in seconds on AIX

Hi, In unix the command "date +%s" displays the date-time in seconds since â00:00:00 1970-01-01 UTCâ (a GNU extension) when executed on unix: -sh-2.05b$ date +%s 1152092690 I tried with all the format control output but unable to display the date-time in seconds i,e as in unix format. Can... (6 Replies)
Discussion started by: me_haroon
6 Replies

10. UNIX for Advanced & Expert Users

file creation date including seconds

Hi, Is anybody can help me to get the file creation date with seconds? -rw-r--r-- 1 opsc system 422550845 Aug 22 15:41 StatData.20020821 Thanks in advance Krishna (7 Replies)
Discussion started by: krishna
7 Replies
Login or Register to Ask a Question