Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not an expert, but I guess in <code>sed</code> you'd first need to append the next line into the pattern space, bij using "<code>N</code>". From the section "Multiline Pattern Space" in "Advanced sed Commands" of the book <a href="http://oreilly.com/catalog/9781565922259/" rel="nofollow noreferrer">sed &amp; awk</a> (Dale Dougherty and Arnold Robbins; O'Reilly 1997; page 107 in <a href="http://oreilly.com/catalog/9781565922259/preview.html" rel="nofollow noreferrer">the preview</a>):</p> <blockquote> <p>The multiline Next (N) command creates a multiline pattern space by reading a new line of input and appending it to the contents of the pattern space. The original contents of pattern space and the new input line are separated by a newline. The embedded newline character can be matched in patterns by the escape sequence "\n". In a multiline pattern space, the metacharacter "^" matches the very first character of the pattern space, and not the character(s) following any embedded newline(s). Similarly, "$" matches only the final newline in the pattern space, and not any embedded newline(s). After the Next command is executed, control is then passed to subsequent commands in the script.</p> </blockquote> <p>From <code>man sed</code>:</p> <blockquote> <p>[2addr]N</p> <p>Append the next line of input to the pattern space, using an embedded newline character to separate the appended material from the original contents. Note that the current line number changes.</p> </blockquote> <p>I've <a href="https://stackoverflow.com/questions/1102986/most-powerful-examples-of-unix-commands-or-scripts-every-programmer-should-know/1103426#1103426">used this</a> to search (multiple) badly formatted log files, in which the search string may be found on an "orphaned" next line.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload