Need command for date format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need command for date format
# 1  
Old 08-27-2014
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)
Code:
2014-08-25

but in my output file it should be
Code:
08/25/2014

please guide me

thanks in advance
hemanthsaikumar
# 2  
Old 08-27-2014
Code:
echo 2014-08-25 | awk -F '-' '{print $2, $3, $1}' OFS='/'

If you have this in a variable, say 'dt'
Code:
echo "${dt}" | awk -F '-' '{print $2, $3, $1}' OFS='/'

# 3  
Old 08-27-2014
Why not adapt the script to accept your output file format?
# 4  
Old 08-27-2014
hi ,
i did it by using the same awk command
its a predefined i cant change the format
Code:
14-08-25

can i get a output like
Code:
08/25/2014

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

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

4. 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

5. 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

6. 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

7. 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

8. HP-UX

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... (2 Replies)
Discussion started by: satyadash
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