I just can’t find my mistake…
I have a csv-file with lines like this:
11;1116209173900;8;4690;000;ÖBB;20090831;20100330;O603;603-Deutschlandsberg;
I’d like to remove the O in front of 603.
My sed command looks like this:
sed 's/\(\(.*;\)\{8\}\)O\(.\{3\}\);/\1\2;/g'
but what I get is
11;1116209173900;8;4690;000;ÖBB;20090831;20100330;20100330;;603-Deutschlandsberg;
Where’s my mistake?
Thank you in advance!
Just a very small change:
You have two levels of parentheses (
\(\(.*;\)\{8\}\)), i.e.\2contains the last match of.*;.Btw.: For performance and unambiguousness reasons I think it’s better to use
[^;]*instead of.*: