$ cat test-sed First line Second line -- Another line Last lineWe can extract the lines from the start of the file to the marker by deleting the rest:
$ sed '/--/,$d' test-sed First line Second line
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-sed -- Another line Last lineThis 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!