From 9a7626ba54fbad40a643f94f8b189168c3830e85 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Fri, 26 Mar 2021 18:20:03 +0100 Subject: [PATCH] Update. --- getbib.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 getbib.sh diff --git a/getbib.sh b/getbib.sh new file mode 100755 index 0000000..e7d2f18 --- /dev/null +++ b/getbib.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Very ugly but handy stuff: loops through the bibtex keys provided as +# arguments, and for each grabs the first bib entry that matches in +# all the found bib files. + +tmp=$(mktemp /tmp/getbib.XXXXXX) + +while [[ "$1" ]] +do + rm -f "${tmp}" + find -type f -name "*.bib" | while read f && [[ ! -s "${tmp}" ]] + do + sed -n '/^[ \t]*@[^{]*{'$1'/,/^[ \t]*}/p' "${f}" > "${tmp}" + done + cat "${tmp}" + echo + shift +done + +rm -rf "${tmp}" -- 2.39.5