Unfortunately, I believe that the standard awk only allows one field delimiter, so you have to pre-process the data. You can do this with tr , but if you really need an awk -only solution, use:
pax> echo '123,01-08-2006 124,01-09-2007 125,01-10-2009 126,01-12-2010' | awk -F, '{print $1"-"$2}' | awk -F- '{print $1","$4"-"$3"-"$2}'
It is output:
123,2006-08-01 124,2007-09-01 125,2009-10-01 126,2010-12-01
optional.
The first awk changes the characters , to - , so you have four fields separated by the same character (this is the bit that I usually used tr ',' '-' for).
The second awk prints them in the order you specify, while adjusting the field separators.
If you are using an awk implementation that allows multiple FS characters, you can use something like:
gawk -F ',|-' '{print $1","$4"-"$3"-"$2}'
source share