Append a line of text after a line matching a pattern
Let's say we've got:
$ cat file.txt
blah
blah blah
append after me
blah bleh!
append after me
blah blah blah
bleeeh
This will add "new stuff" after every line that says "append after me":
$ sed -i '/append after me/a new stuff' file.txt
Bingo:
$ cat file.txt
blah
blah blah
append after me
new stuff
blah bleh!
append after me
new stuff
blah blah blah
bleeeh
Leave a comment