From: Francois Fleuret Date: Fri, 26 Mar 2021 17:20:03 +0000 (+0100) Subject: Update. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=9a7626ba54fbad40a643f94f8b189168c3830e85;p=scripts.git Update. --- 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}"