Here’s some hints on using sed.

In place replacements

In-place replacement (GNU)

sed -i -e 's/foo/bar/' example.md

In GNU sed: use -i without arg.

In-place replacement (BSD)

sed -i '' -e 's/foo/bar/' example.md

In OSX, -i '' is required.

File regions

sed '/begin api/q'
sed '/^# begin/,$d'
sed -n '/end api/,$p'

Print after a given line is found.

sed -n '/regex/d;'

Print everything except lines matching regex. Useful for printing files with comments.