Using grep (well, pcregrep) to display the labels of reference style links in a Markdown document:
$ pcregrep --only-matching=1 \ # Only display the match from group 1
"\[.*?\](\[.*?\])" \ # Find [text][label] reference style links
/path/to/document.md | \ # Path to the markdown document
sort # Optionally sort the output
I had the regexp working in grep but couldn't capture just the group I was interested in. This Stack Overflow answer suggested pcregrep
.