Skip to main content
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 267
Source Link
SSDdude
  • 171
  • 2
  • 13

Change all but first ',' to "<COMMA>" for each row in file (bash)

I am using bash and have a csv file (dat.csv) that needs to be only two columns (App, Blurb) of data but due to many ',' on each row it is becoming MANY columns.

EXAMPLE OF PROBLEM csv.dat:

 App , Blurb diff, this is the diff program, bla bla bla, yadda yadda word, this is ms product, it is not very good, I dont like it dd, this is a Linux disk application , its awesome!, bla bla, ttly ... 

The problem I am having is that because the 'Blurb' col has additional ',' the data is getting piped into subsequent columns (c, d, etc) of the dat.csv file.

THE GOAL is to have all but the first ',' from every row be changed to "COMMA" so all the 'Blurb' data remains in col B.

E.g. DESIRED OUTPUT:

 App, Blurb diff, this is the diff program<COMMMA> bla bla bla<COMMA> yadda yadda word, this is ms product<COMMA> it is not very good<COMMA> I dont like it dd, this is a Linux disk application <COMMA> its awesome!<COMMA>bla bla<COMMA> ttly ... 

Thanks!