Answer the question
In order to leave comments, you need to log in
How to insert text between lines using sed?
It is necessary to insert a part of the text between lines containing certain substrings (or falling under a regular expression).
Answer the question
In order to leave comments, you need to log in
Well, now the question makes more sense. The clarification problem is solved as follows:
echo -e "aaa\nbbb\naaa\nddd" | sed '/aaa/{n;/bbb/i new_line
}'
It is not entirely clear what it means between the lines. But anyway:
a. if you need to insert after the line with the template:
echo -e "1\n2\n3\n4" | sed '/2/a test'
echo -e "1\n2\n3\n4" | sed '/2/,/4/a test'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question