Say we want to read some file contents between a set of markers, like the frontmatter of a markdown document, for example:
blog-post.md
---
title: My first blog post
tags:
- blog
- first
- thing
---
# Welcome to my blog
Lots of interesting content.
We can use sed to read the content contained within the --- markers with:
sed-n'/^---$/,/^---$/p'blog-post.md
We're telling sed to print all lines in the range defined by matches of the pattern. If we want to exclude the markers themselves, we can delete them by extending the command: