I need to insert some lines of code into a file. The problem is, I want to insert it after some function calling AND after the semicolon behind it, too.
I'd like to achieve this just with
sed, but I don't know why.
Source code snippet:
10 printf("asdf"); 11 12 myFunc() 13 14 ;
Here I want to insert the snippet behind the
myFunc() call, but I can't insert it directly to the line 13, but to the line 15.
Desired code after insertion:
10 printf("asdf"); 11 12 myFunc() 13 14 ; 15 SNIPPET
My best attempt is this:
sed -e '13 i\SNIPPET'
Which obviously doesn't "wait" for the semicolon.
So, is there any way I could combine those conditions, so I'd insert my code snippet after the first semicolon after the line number ***?