X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=scripts.git;a=blobdiff_plain;f=getbib.sh;fp=getbib.sh;h=e7d2f18b88ac8799af3a9211eea1f85c3cfbbac3;hp=0000000000000000000000000000000000000000;hb=9a7626ba54fbad40a643f94f8b189168c3830e85;hpb=168fb874818be5acaf78953efb56f46db7413131 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}"