add newline in file after finding specific text

Hi All,

I am tring to insert a newline with "/" in a text file whenever there is the text "end;"

right now I have inside file:
.
.
end;

I want to have:
.
.
end;
/

I tried doing the following within the file

:g/^end;/s//end; \/ /

but it is not putting the "/" on a new line. It is giving me instead
.
.
end; /

Try this...

sed 's/^end;/&\n\//g' yourfile

You need to tell it to insert a newline as well. Did you try using a ^M? If using vi just press cntrl-v then press the enter key. That will put the return character into place. One more thing is that you need to escape the semicolons as well.

so it should be typed in as

:g/^end\;/s//end\;^M\/ /

Thanks Malcom and Bubba,

the sed command worked.

Bubba, I tried your suggestion but it did not work. Perhaps because I am using bash instead of Korn or C shell ?

try. i use bash

sed 's|end;|& \n/|' file