Home » Infrastructure » Unix » Date formatting in unix shell script
Date formatting in unix shell script [message #295640] Tue, 22 January 2008 23:43 Go to next message
vanathi
Messages: 74
Registered: December 2007
Location: India
Member
Hi,
I have 01172008 date. I have to change it to 17-jan-2008 in a shell script.

Please advice.
Re: Date formatting in unix shell script [message #295661 is a reply to message #295640] Wed, 23 January 2008 00:51 Go to previous messageGo to next message
Michel Cadot
Messages: 59399
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is not an Oracle question, please note that this an Oracle forum.

> date +'%e-%b-%Y'
23-Jan-2008

Regards
Michel

[Updated on: Wed, 23 January 2008 00:51]

Report message to a moderator

Re: Date formatting in unix shell script [message #295664 is a reply to message #295661] Wed, 23 January 2008 00:59 Go to previous messageGo to next message
vanathi
Messages: 74
Registered: December 2007
Location: India
Member
Sorry Michel.
I am having that 01172008 in a variable. It is not denoting the today's date. It come from a file dynamically.
Re: Date formatting in unix shell script [message #295769 is a reply to message #295664] Wed, 23 January 2008 06:30 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

You could apply this
With some small modifications it will suit your needs.
Re: Date formatting in unix shell script [message #295771 is a reply to message #295769] Wed, 23 January 2008 06:36 Go to previous message
vanathi
Messages: 74
Registered: December 2007
Location: India
Member
I tried it another way and got it.

mVar=01172008 --> consider

mYear=`echo $mVar | cut -c 5-8`
mDay=`echo $mVar | cut -c 3-4`
mMth=`echo $mVar | cut -c 1-2`
mAllMths='Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'
mMthOut=`echo ${mAllMths} | cut -d' ' -f${mMth}`

filegendatetime="$(echo ${mDay}'-'${mMthOut}'-'${mYear})"

This is working now.

Thanks for your effort.

[Updated on: Wed, 23 January 2008 06:38]

Report message to a moderator

Previous Topic: SMTP service
Next Topic: Oracle Installation Permissions Problem
Goto Forum:
  


Current Time: Mon Oct 20 05:44:52 CDT 2014

Total time taken to generate the page: 0.09813 seconds