# Capturing contents within Curly Brackets

OK, just a quickie here. I’m working with a colleague on a manuscript using LaTeX. The citation formatting for the journal we are looking at uses the numerical citations but bibtex will number the citations by the order in which the \bibitem values they occur in the bibliography section. So, it would be great to get them to be in the order in which they occur in the text.

So, our old friend (and sometimes enemy) grep comes to the rescue. Here is a quick one-liner that allows you to search the text for all the \cite{} entries and return only the contents within the curly brackets.

cat test.tex | grep -o -e "cite{[^}]*}"

Once all the editing is done and we’ve finished on the main body of the text, we can reorder the bibliography section and the numbers will be incremental.

Sometimes I forget how awesome and powerful the unix underpinnings are.

###### Father, Husband, Brewer, Professor

Middle aged guy trying to keep it all together and figure out how to best navigate the world as it is. Technology geek, practitioner of fermentation sciences, researcher, biologist.