Issue
I need to sanitize a CSV that lists some numbers. For 4 and more digits, it gives the number in double quotes with comma. I need to remove this type of comma.
sed 's/"[0-9]*\,[0-9]*"/"idk"/g'
Which successfully identifies the comma I am looking for apart from the other commas.
example,134,"idk",0.91%,8.0
example,96,"idk",2.62%,6.9
example,89,367,3.68%,5.8
How do I tell sed I only need to remove the comma out of the match query though?
Edit: Sorry, expected output is just to remove the comma.
in: example,89,"1,456",3.68%,5.8
out: example,89,"1456",3.68%,5.8
Solution
You tell sed to "remember" the other parts and use them in replacement string. Ie. use a backreference.
sed 's/\("[0-9]*\),\([0-9]*"\)/\1\2/g'
Answered By - KamilCuk Answer Checked By - Cary Denson (WPSolving Admin)