The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
change timestamp of file isingh786 HP-UX 1 05-15-2006 10:56 AM
Create file with old timestamp Kris_Kart_101 UNIX for Dummies Questions & Answers 2 10-14-2005 10:18 AM
changing timestamp of a file krishan SUN Solaris 1 05-23-2005 07:50 AM
timestamp of file krisdhar UNIX for Dummies Questions & Answers 4 10-28-2003 07:31 AM
putting a timestamp in a file rocker40 UNIX for Dummies Questions & Answers 2 10-22-2003 08:56 AM

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

Join Date: Aug 2005
Posts: 111
Question File timestamp

Hi,

Could someone please tell me how to find the last modified date (date,hours,minutes,seconds) of a file in the format YYYY-MM-DD hh:mm:ss of a file using only standard HP-UX commands?

I looked for options in "ls" command but I couldn't find any options for HP-UX which gets the date details upto the seconds.

Any help will be greatly appreciated.

Cheers
Steve
Reply With Quote
Forum Sponsor
  #2  
Old 12-24-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,663
Ok let's say that the name of the file is "junk". On HP-UX you can do:
perl -e '@d=localtime ((stat(shift))[9]); printf "%4d-%02d-%02d %02d:%02d:%02d\n", $d[5]+1900,$d[4]+1,$d[3],$d[2],$d[1],$d[0]' junk

And yes, perl comes with HP-UX. It is in /usr/contrib. But you may have a more recent version in /usr/local or /opt.
Reply With Quote
  #3  
Old 12-24-2007
Registered User
 

Join Date: Aug 2005
Posts: 111
Smile

Thank you Perderabo!

It works great but is it possible to do it with either "sed" or "awk" ?

Cheers
Steve
Reply With Quote
  #4  
Old 12-24-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,663
Quote:
Originally Posted by stevefox View Post
It works great but is it possible to do it with either "sed" or "awk" ?
No. All they can do is manipulate the output of ls which simply does not present enough information.
Reply With Quote
  #5  
Old 12-24-2007
Registered User
 

Join Date: Aug 2005
Posts: 111
Smile

Ok,
Thanks alot Perderabo!

Cheers
Steve
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 05:48 PM.


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