Sed Replace repeating pattern

Hi,

I have an sqlplus output file using the character ';' as a delimiter and I would like to replace the fields without datas (i.e delimited by ';;') by ';0;'

Example: my sqlplus output:

11;22;33;44;;;77;;

What I would like to have:

11;22;33;44;0;0;77;0;

Thanks in advance for your help!

 echo '11;22;33;44;;;;;77;;' | sed 's/;;/;0;/g;s/;;/;0;/g'
1 Like

Thanks,

Your command is working fine!