Skip to main content
clarified title ("every second" implies a sequence)
Link
steeldriver
  • 83.8k
  • 12
  • 124
  • 175

How can I remove everythe second comma in each row of a csv file using sed?

Source Link

How can I remove every second comma in each row of a csv file using sed?

I have a bunch of csv files in a directory, and I want to remove from each row the second comma. Example:

Input:

53,900,1001,-45.4247,9.87187,541.65
75,900,0102,37.0896,4.24087,558.35
75,900,1101,37.3096,4.25814,561.65
46,901,0003,-51.3833,-20.2645,578.35
3,901,0003,-57.302,-23.0063,578.35

Desired Output:

53,9001001,-45.4247,9.87187,541.65
75,9000102,37.0896,4.24087,558.35
75,9001101,37.3096,4.25814,561.65
46,9010003,-51.3833,-20.2645,578.35
3,9010003,-57.302,-23.0063,578.35

Is this possible with sed? Many thanks in advance!