The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
whats command for search including sub directory ? gksenthilkumar UNIX for Advanced & Expert Users 2 03-01-2008 03:09 AM
including a library file ????? skyineyes Shell Programming and Scripting 6 01-18-2008 12:55 AM
check the file every 15 seconds alisevA3 Shell Programming and Scripting 4 06-24-2005 09:19 AM
HELP! The '/var/adm/message' file increase every few seconds??? cloudsmell Filesystems, Disks and Memory 1 09-16-2002 09:31 PM
file creation date including seconds krishna UNIX for Advanced & Expert Users 7 08-26-2002 08:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-08-2007
firdousamir firdousamir is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 25
Unhappy 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 (permalink)  
Old 08-08-2007
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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 (permalink)  
Old 08-08-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
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
  #4 (permalink)  
Old 08-08-2007
firdousamir firdousamir is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 25
ls -l --full-time is not working however. Is the precision configurable? I mean somewhere in the /etc ?
  #5 (permalink)  
Old 08-08-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
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 (permalink)  
Old 04-25-2009
sniper57 sniper57 is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 17
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 (permalink)  
Old 05-08-2009
Ruks Ruks is offline
Registered User
  
 

Join Date: May 2009
Posts: 9
hey.. i got it.. that is the output of that cmd.. :P.. but hw can we get it assigned to a variable???
Closed Thread

Bookmarks

Tags
perl, perl shift, shift, shift perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0