I have a textfile which contains some service usage data. I want to replace every dot (.) with a comma (,). This needs to be done due to decimal seperator inconsitancy. Then remove all spaces, then separate every column with a semikolon (;).
Original Data:
A.FOOBAR 0.000 0.000 0.000 0.000 0.061 0.000 0.000 0.061
AFOOB.BI 0.000 0.000 0.000 0.000 0.085 0.000 0.000 0.085
ABFOOB 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
ABFUUUA 0.000 0.000 0.000 0.000 0.061 0.000 0.000 0.061
ACFOO.GA 0.000 0.000 0.000 0.000 0.061 0.000 0.000 0.061
ADFOO.BA 0.000 0.000 0.000 0.000 0.061 0.000 0.000 0.061
AFOO.ER 0.000 0.000 0.000 0.000 0.061 0.000 0.000 0.061
AFBARFE1 0.000 0.000 0.000 0.000 0.061 0.000 0.000 0.061
AGFOOFD 0.000 0.000 0.000 0.000 0.061 0.000 0.000 0.061
AGFOOO.K 0.000 0.000 0.000 0.000 0.061 0.000 0.000 0.061
My current regex looks like:
echo in.txt > sed -r 's/[[:blank:]]+/;/g' | sed -r 's/\./,/g'
This results in
A,FOOBAR;0,000;0,000;0,000;0,000;0,061;0,000;0,000;0,061
AFOOB,BI;0,000;0,000;0,000;0,000;0,085;0,000;0,000;0,085
ABFOOB;0,000;0,000;0,000;0,000;0,000;0,000;0,000;0,000
Of cource this matches also the first dot... I cannot use the 2g-Operator because not every username contains a dot. How am I able to "not match" the first 8 characters?
Thanks a lot!