For reference for my future self, a few handy sed commands. Let’s consider this file:
$ cat test-sedWe can extract the lines from the start of the file to the marker by deleting the rest:
$ sed '/–/,$d' test-sed
a,bis the range the command, here
d(elete), applies to.
bcan be, among others, line numbers, regular expressions or
$for end of the file. We can also extract the lines from the marker to the end of the file with:
$ sed -n '/–/,$p' test-sedThis one is slightly more complicated. By default sed spits all the lines it receives as input,
’-n’is there to tell sed not to do that. The rest of the expression is to
p(rint)the lines between
–and the end of the file.
That’s all folks!