To append two columns without double quotes

Hi i have a file with follw data

"20090427","0","","16371311","-100200","","","","16371311","JUL","09"

In the 10th column i need to convert the month name into month number in this case JUL will be 7 and append the 10th and 11th column which shows me the output as 709. Can you suggest a shell script or which commands should i go for ,i tried doing awk and sed but not getting the desired output.

$  ruby -F"," -rdate  -ane '$F[9]=Date.parse($F[9]).strftime("\"%m")+$F[10].chomp[1..-1];puts $F[0..-2].join(",")' file
"20090427","0","","16371311","-100200","","","","16371311","0709"

Try:

perl -F"," -nlae 'BEGIN{%m=("JAN","1","FEB","2","MAR","3","APR","4","MAY","5","JUN","6","JUL","7","AUG","8","SEP","9","OCT","10","NOV","11","DEC","12")};$F[9]=~s/"//g;$F[10]=~s/"//g;print "$m{$F[9]}$F[10]"' file

Sorry, i couldnt understand the logic, actually i need unix commands to get the output. I am currently using ksh :confused:

---------- Post updated at 07:43 AM ---------- Previous update was at 07:40 AM ----------

I tried this command awk '{print $10 $11}' FS="," test.txt | sed -e "s/JUL/7/g" but that gives me the output as "7""09" whereas i need only 709 without double quotes.

---------- Post updated at 07:46 AM ---------- Previous update was at 07:43 AM ----------

This command only goes if i consider july as the month

You can run that Perl line in the command line...

Hey thanks so much it worked.

With awk:

awk -F\" '
{s=$22;sub("," FS $22 FS,"")}
{$20=sprintf(index("JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC",$20)+2)/3 s}
1' OFS=\" file

@bartus, what a humongous piece of Perl one-liner.

Hey can u please explain me the logic wat u have used, wat does the index function is exactly doing, Y $22 is considered etc

---------- Post updated at 12:42 AM ---------- Previous update was at 12:36 AM ----------

Hey can u explain me the awk logic wat u have used

awk -F\" '
{s=$22;sub("," FS $22 FS,"")}
{$20=sprintf(index("JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC",$20)+2)/3 s}
1' OFS=\" file
index("JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC",$20)+2)/3

The index function gives the position of the 2nd parameter in the 1st parameter:

JAN gives position 1; (1 + 2)/3 = 1
FEB gives position 4; (4 + 2)/3 = 2
MAR gives position 7; (7 + 2)/3 = 3
.
.

Hi , what does $20 refer to in this case.

Note that the field separator is a double quote so it refers to the column with the month name.