Reputation:
How can a sed result be inserted into another file directly at a specific point of patterned string ? as below just clarifying illustration:
sed -E 's/foo/foo\0bar/' foo | sed -E '/^bar$/i{ }' bar # ?
so insert { }
inside the bar file at position of line being a bar
string
Upvotes: 0
Views: 50
Reputation: 58528
This might work for you (GNU sed):
sed '/bar/e sed -n "\\#foo#p" file1' file2
This will insert the line(s) matching foo
in file1 before line(s) matching bar
in file2.
Upvotes: 1