[Tex/LaTex] How to use a command-line tool to extract a bibtex reference that contains a search term


I'd like to be able to use a tool like grep to extract an entire bibtex reference rather than just the matching line.
For example, grep Smith mydatabase.bib would return lines that contain the word Smith. I'd like to have a command-line program that returned the entire bibtex reference that encloses the word Smith.

  • How can this be done on the command-line?

In particular, I'd be interested in whether there is a way of using sed or awk to perform the task?

Best Answer

bibtool --select {"Smith"} <file>.aux -o <file>.bib creates a new bibliography data file which has only entries with Smith.

bibtool should be part of your TeX distribution.