Juan C. Bravo Celis Juan C. Bravo Celis - 2 months ago 7
Linux Question

how to replace decimal in linux

I have a csv file with error in one field, the fields are separated by

","
but the error is in decimal field, for example
34.25,"
i need replace by
34.25","
.

Search
,"
and replace by
","
is not option, others fields will modified.

Answer

Check that the character before ," is not a double quote, and if it's not, add the double quote:

sed 's/\([^"]\),"/\1","/'