I want to search for a pattern across two consecutive lines and use part of that pattern to change part of the second line. I haven't been able to find anything about sed that would show me how to do it.
Everything I have found shows how to merge lines and add new blank lines but nothing shows how to do what I want.
I can do this all day long in Vim but I want to do it in the bash shell using sed or sed & awk or something else because I have several dozen files to do this on and opening them in Vim is painfully slow.
This single line below will find a pattern across two consecutive lines then put back everything one the first line and the second line with some added content.
s_^\([ </p>]*<h2 id="\)\(b0[0-9][0-9]c[0-1][0-9][0-9]\)\(" class="chapter">[0-9]\+</h
2><p>\)\n\([ ]*\)\([A-Z]\)_\1\2\3\r\4<span id="\2v001" class="verse">1</span> \5_
Does anyone know how to do this with sed or something else on the shell cli?