Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Is this case sensitive? My input only has N, not n (also what was the difference between the two posts (before and after editing) Commented Jul 16, 2015 at 18:31
  • @LynneSmith - I just wrote an explanation about the second one. Where either N or n do not occur within an / address / it is because they are the sed commands for append Next input line to pattern space and overwrite pattern space with the next input line, and so are not relevant to the N match. Commented Jul 16, 2015 at 18:35
  • Also, why in 4 input lines does it pull lines until 3 \n are found? The fourth line is included in the block that is removed, right? Commented Jul 16, 2015 at 18:38
  • @LynneSmith - Yes, the \n is appended to the current line, and precedes that pulled in. So: printf %s\\n 1 2 3 4 | sed 'N;N;N;l;d will print: 1\n2\n3\n4 - all 4 lines are in pattern space, but only 3 delimiters are present - because the \newline occurs between input lines in pattern space. Commented Jul 16, 2015 at 18:41