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?

4

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

s/;;/;/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.