To select all the lines starting from STARTING_PATTERN up to blank line ^$ and then delete those lines.
# sed ‘/STARTING_PATTERN/,/^$/d’ filename
To edit files in place, use -i option.
# sed -i ‘/STARTING_PATTER/,/^$/d’ filename
Insert multiple lines into a file after specified pattern.
# sed ‘/cdef/r add.txt’ input.txt
# sed ‘/cdef/r add.txt’ input.txt
input.txt: abcd accd cdef line web | add.txt: line1 line2 line3 line4 |
Output : abcd accd cdef line1 line2 line3 line4 line web |
If you want to apply the changes in input.txt file. Then, use -i with sed.
# sed -i ‘/cdef/r add.txt’ input.txt
If you want to use a regex as an expression you have to use the -E tag with sed.
# sed -E ‘/RegexPattern/r add.txt’ input.txt