Format a date in a csv file

So I have a csv file where the 3rd field is a date string in the format yyyy-mm-dd. I need to change it to mm/dd/yyyy. So each line in the csv file looks like:

StringData,StringData,2009-02-17,12.345,StringData
StringData,StringData,2009-02-16,65.789,StringData

Any idea how I can keep everything else in place and just change the date format on that 3rd field for each line?

Thanks,
Ric

One approach:

awk -F, '{split($3,a,"-");$3=a[2]"/"a[3]"/"a[1]}1' OFS=, file

Regards

You rick. That's perfect. I knew awk was the answer but I'm new to unix scripting so didn't know how to get there. Thanks again!

Hi Franklin52,

In your awk command, what does the '1' stands for ? I am refering to the 1 after {} in the awk command, but before closing the single quote (i.e. awk ... '{...}1' ).

thanks

awk evaluates the "1" after the brace as true and the prints the current line by default, equivalent to {print}.

Regards

sed 's/\([0-9][0-9]*\)-\([0-9][0-9]*\)-\([0-9][0-9]*\)/\2\/\3\/\1/' a.txt