How to change number format (different decimal separator) from XXXXXX.XXX to XXXXXX,XXX using sed or awk?
How to change number format (different decimal separator) from XXXXXX.XXX to XXXXXX,XXX using sed or awk?
To substitute only the decimal commas in this line:
Total,"14333,374","1243750945,5","100,00%","100,00%","100,00%",1 639 600,"100,00%"
I used back-references (and MacOSX, so I need the -E option):
echo 'Total,"14333,374","1243750945,5","100,00%","100,00%","100,00%",1 639 600,"100,00%"' | sed -E 's/("[0-9]+),([0-9]+%?")/\1\.\2/g'
resulting in
Total,"14333.374","1243750945.5","100.00%","100.00%","100.00%",1 639 600,"100.00%"
The sed command says: "Find every string of the form 'double quotes digit_1,digit_2, followed by one or zero %, double quotes' and replace it by first_match.second_match."