fork download
  1. #!/bin/bash
  2. str='first , second ,, third, ,fourth suffix'
  3. sed -E 's/[[:space:]]*(([,[:space:]])[[:space:]]*)+/\2/g' <<< "$str"
Success #stdin #stdout 0.01s 5536KB
stdin
Standard input is empty
stdout
first,second,third,fourth suffix