awk -v does nt seem to work.
awk -v var="01-JUL-00" '
BEGIN{
split("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC", month, " ")
for (i=1; i<=12; i++) mdigit[month[i]]=i
m=toupper(substr(var,4,3))
dat="20"substr(var,8,20)substr(var,1,2) sprintf("%02d",mdigit[m])
print dat
}'
awk: syntax error near line 1
awk: bailing out near line 1
So i tried this
echo $var | awk 'BEGIN{FS="-";OFS="";split("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC", month, " ")
for (i=1; i<=12; i++) mdigit[month[i]]=i
m=toupper(substr(var,4,3))
dat="20"substr(var,8,20)substr(var,1,2) sprintf("%02d",mdigit[m])
print dat}'
and the output is 2000 and not 20070701
Any suggestions??