bash - Remove consecutive duplicate comma in a text file -


i have text file name file.txt contains

remo/hello/1.0,remo/hello2/2.0,,remo/hello3/3.0,whitney/hello/1.0,,,julie/hello/2.0,,,,remo/hello2/2.0,,remo/hello3/3.0,, 

i want delete consecutive duplicate commas(,) in file after deleting output file should this

output.txt

remo/hello/1.0,remo/hello2/2.0,remo/hello3/3.0,whitney/hello/1.0,julie/hello/2.0,remo/hello2/2.0,remo/hello3/3.0, 

i have tried below code:

awk '!seen[$0]++' filename 

but didn't work out.

please tia.

use tr "squeeze" consecutive commas

tr -s , <input >output 

Comments