Timeline for Remove x lines before and y lines after nth line (which matches a pattern) in a file
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 16, 2015 at 18:44 | vote | accept | Lynne Smith | ||
| Jul 16, 2015 at 18:44 | |||||
| Jul 16, 2015 at 18:41 | comment | added | mikeserv | @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. | |
| Jul 16, 2015 at 18:38 | comment | added | Lynne Smith | 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? | |
| Jul 16, 2015 at 18:35 | comment | added | mikeserv | @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. | |
| Jul 16, 2015 at 18:33 | history | edited | mikeserv | CC BY-SA 3.0 | Might as well use a function there, I guess. |
| Jul 16, 2015 at 18:31 | comment | added | Lynne Smith | Is this case sensitive? My input only has N, not n (also what was the difference between the two posts (before and after editing) | |
| Jul 16, 2015 at 18:25 | history | edited | mikeserv | CC BY-SA 3.0 | Might as well use a function there, I guess. |
| Jul 16, 2015 at 18:19 | history | edited | mikeserv | CC BY-SA 3.0 | Might as well use a function there, I guess. |
| Jul 16, 2015 at 17:48 | history | edited | mikeserv | CC BY-SA 3.0 | added 21 characters in body |
| Jul 16, 2015 at 17:28 | history | answered | mikeserv | CC BY-SA 3.0 |