Help with removing additional commas in string

Hi Experts,

I have below strings

hello,hi,,,,,,start date
age,code,,,,,61,season

I am trying to format this string to

hello,hi,start date
age,code,61,season

Can anyone please help me in achieving this?

Kind Regards,
RB

Try:

sed 's/[,][,]*/,/g' file
1 Like

Try

tr -s "," < filename

cheers,
Devaraj Takhellambam

Thanks to anchal and dev for your quick replies.

I was looking for a solution in perl. I used the sed code given by anchal and modified to suit perl. Its working absolutely as I required.

Special thanks to anchal

Regards,
RB