Go Back   The UNIX and Linux Forums > Operating Systems > HP-UX
google site



HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-07-2009
Registered User
 

Join Date: Dec 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Date format of ll command

Hi,

Unix: HP-UNIX.

I have a requirement(part of my requirement) to get latest file modification date of all files(In a particular directory).

Using ll comand i m able to find out the modification date but not in the required format

My command and out put:
echo trp_pb.sql `ll trp_pb.sql|awk '{print $6 $7 $8}'`
Output:
trp_pb.sql Jan262007


I need the date in MM/DD/YYYY format.

Thanks in advance.

Regards,
Satya
Sponsored Links
  #2  
Old 12-07-2009
Registered User
 

Join Date: May 2009
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

Try a tiny shell script like:

Code:
   mm=`expr substr "$6" 1 2`
   dd=`expr substr "$7" 3 2`
   yyyy=`expr substr "$8" 5 2`"
   echo "$dd/$mm/$yyyy"

Regards.

Last edited by pludi; 12-07-2009 at 05:31 AM.. Reason: code tags, please...
  #3  
Old 12-07-2009
Registered User
 

Join Date: Dec 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Ganesh,

The below code does not give correct output.


Code:
mon=$(echo `ll prp_ps.sql|awk '{print $6}'`)
day=$(echo `ll prp_ps.sql|awk '{print $7}'`)
year=$(echo `ll prp_ps.sql|awk '{print $8}'`)
mm=`expr substr "$mon" 1 2`
dd=`expr substr "$day" 3 2`
yyyy=`expr substr "$year" 5 2`
echo "$dd/$mm/$yyyy"

And output is :
/No/

But actual date is

Code:
ll prp_ps.sql 
-rw-r--r-- 1 dashs sicalis 2572 Nov 25 2008 prp_ps.sql

Any help???

Regards,
Satya

Last edited by pludi; 12-07-2009 at 05:32 AM.. Reason: code tags, please...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Changing from Excel date format to MySQL date format figaro UNIX for Dummies Questions & Answers 2 08-11-2009 03:23 PM
Which is the STRING format in the date command? islegmar Shell Programming and Scripting 1 03-19-2009 08:33 AM
convert date format to mysql date format in log file hazno Shell Programming and Scripting 3 03-03-2009 08:05 AM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 07:42 PM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-27-2006 11:30 PM



All times are GMT -4. The time now is 03:01 AM.