Date format of ll command


 
Thread Tools Search this Thread
Operating Systems HP-UX Date format of ll command
# 1  
Old 12-07-2009
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
# 2  
Old 12-07-2009
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 06:31 AM.. Reason: code tags, please...
# 3  
Old 12-07-2009
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 06:32 AM.. Reason: code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to check date format DDMMYYYY

Record: Record1|Record2|Record3|Record4|Record5|DATE1|DATE2 Need to Check DATE1 & DATE2 is in DDMMYYYY format in a file. records which not meet the date format DDMMYYYY extract to other file. (1 Reply)
Discussion started by: vivekn
1 Replies

2. Shell Programming and Scripting

Date command comparision with a different format

I have a script called " passwd_status " which gives the passwd-s status of my servers. the script output is like below password status for A: abc ks 10/05/115 1 30 ps password status for B: abc ks 09/25/115 1 30 ps password status for C: abc ks 10/10/115 1 30 ps Now , i want to... (1 Reply)
Discussion started by: charanarjun
1 Replies

3. Shell Programming and Scripting

Need command for date format

hi all, i had a requirement in my script iam passing the parameter like (its not the system date iam passing as argument like it can be any date) 2014-08-25 but in my output file it should be 08/25/2014 please guide me thanks in advance hemanthsaikumar (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

4. Shell Programming and Scripting

Date command format

Hi, I need to convert a date format "August 12, 2013 9:40:00 PM CDT" in to DD/MM formant For example ..I am using ... date -d "January10, 2013 04:05:00 AM CST" +%m/%d which gives me... 01/10 However, when i'am using it against every month it is throwing errors on some months as... (3 Replies)
Discussion started by: Kevin Tivoli
3 Replies

5. UNIX for Dummies Questions & Answers

Rename all Files in a UNIX Directory from one date format to another date format

Hi Unix Gurus, I would like to rename several files in a Unix Directory . The filenames can have more than 1 underscore ( _ ) and the last underscore is always followed by a date in the format mmddyyyy. The Extension of the files can be .txt or .pdf or .xls etc and is case insensitive ie... (1 Reply)
Discussion started by: pchegoor
1 Replies

6. Shell Programming and Scripting

Display date in mm/dd/yy format in sed command

Hi All, Following is my issue. $MAIL_DOC = test.txt test.txt contains the following text . This process was executed in the %INSTANCE% instance on %RUNDATE%. I am trying to execute the following script var=`echo $ORACLE_SID | tr ` NOW=$(date +"%D") sed -e... (3 Replies)
Discussion started by: megha2525
3 Replies

7. Shell Programming and Scripting

Command for changing date format in a file

Hi... I have an inputfile name as :- abc_test_20120213.dat (date in yyyymmdd format) I need the output file name as abc_test_13022012.dat (date in ddmmyyyy format) Please help me on this... Thanks in advance. (5 Replies)
Discussion started by: gani_85
5 Replies

8. Shell Programming and Scripting

How to change date format in 'last' command?

hi.. i am new to here. can anybody tell me how can we change the date format in the 'last' command. EX- on running last command i am getting -- rruat pts/12 172.18.40.101 Tue May 3 12:59 still logged in rruat pts/10 blr2-3f-239.asco Tue May 3 12:59 - 13:09 ... (2 Replies)
Discussion started by: thearpit
2 Replies

9. Shell Programming and Scripting

Which is the STRING format in the date command?

Hi According with the 'date' command documentation My question is, which are the possible values for STRING? I have been looking in the man pages but I didn't find anything? After some googling I have found it can have special values as 'now', 'yesterday' or 'tomorrow'. If it represents... (1 Reply)
Discussion started by: islegmar
1 Replies

10. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies
Login or Register to Ask a Question