The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
converting unix timestamp into readable format using c++ uselessprog High Level Programming 3 04-07-2008 12:07 PM
Formatting of file to an desired one pkondur Shell Programming and Scripting 5 04-01-2008 10:26 PM
Desired Format ! prasanth_babu HP-UX 1 02-20-2008 07:31 AM
capturing the time stamp in desired format pavan_test UNIX for Dummies Questions & Answers 2 09-21-2006 05:17 PM
how to convert from timestamp to date format in tcsh umen Shell Programming and Scripting 2 11-22-2005 01:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-08-2007
Registered User
 

Join Date: Nov 2006
Posts: 28
get the timestamp of a file in desired format

Hi,

I have a file say abc. I get the timestamp in following way:

ls -ltr abc | awk -F" " '{print $6,$7,$8}'

Mar 8 10:23

I need to get the timestamp as :

03-08-2007 10:23:00

Thanks
Sumeet
Reply With Quote
Forum Sponsor
  #2  
Old 03-08-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
This is one line with perl...

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]' file1.txt
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0