0

Hi I have a logfile and I want to replace the first semicolon occurence, like:

head1;head2;head3;head4;head5 
blabb;blabl;;blab;blabl;;bla

Desired output:

 head1;head2;head3;head4;head5 
 blabb;blabl;blab;blabl;;bla

With regular expression how can select the first occurrence and replace for ";" I have the next command in sed:

sed -i 's/;;/;/g'

but this one replace all the occurrences file. Is there another way to do?

1 Answer 1

4

To make the substitution only act once, remove the /g modifier:

s/;;/;/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .