I have a(n R Markdown) script that contains plain text, plus delimited chunks of bash code that look like this:
```{bash, title-of-chunk, other=TRUE, options=FALSE}
# here's some bash code
blah_blah="blah"
```
I would like to extract all of the bash code chunks into a separate document. The rub is that I would like the different code chunks to be labeled by a comment title-of-chunk. So the result would look like
# title-of-chunk
# here's some bash code
blah_blah="blah"
The chunk title will always be between the first two .'s.
I've been working with sed, but haven't found the right combination yet.