I've got a file with all Belgian cities. Some of these cities have boroughs. Lier;stad;Antwerpen;49,70;33930;Lier;KoningshooiktKnokke-Heist;gem.;WestVlaanderen;56,44;33825;Knokke;Westkapelle;Heist;RamskapelleBut I want to divide the boroughs with , and space instead of ;. So I want to get this:Lier;stad;Antwerpen;49,70;33930;Lier, KoningshooiktKnokke-Heist;gem.;West-Vlaanderen;56,44;33825;Knokke, Westkapelle, Heist, RamskapelleI use vi regularly but this kind of substitution is hard for me.
vi -- replace chars from part of line
sed;vi;command substitution
You could do (assuming GNU sed)::%!sed 's/;/, /6g'To replace the 6th to last ; with ,.With vim using look-behind operators::%s/\v((;.*){5})@<=;/, /g(that is replace the ;s that are preceded by at least 5 ;s).