script for month conversion in numeric format

Hi Experts,

How to convert months into numeric format with the help of some script:

Suppose I want:
" Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sept | Oct | Nov | Dec "

to be converted as :

" 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 "

Thanks in advance.

echo " 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 "

Is there a point to this?

you can use this awk script..
where MM is variable to which you pass your month name...

awk -v MM="Feb" 'BEGIN{
 x="Jan 01 Feb 02 Mar 03 Apr 04 May 05 Jun 06 Jul 07 Aug 08 Sep 09 Oct 10 Nov 11 Dec 12"
split(x,data)
for(i = 1 ; i < 25  ; i += 2)
{
mon[data]=data[i+1]
}
{printf mon[MM]}
}'
1 Like