Skip to content

Instantly share code, notes, and snippets.

@scemama
Forked from TApplencourt/get_bibtex.sh
Last active November 22, 2021 18:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scemama/2fba1c38835fa4f36aca to your computer and use it in GitHub Desktop.
Save scemama/2fba1c38835fa4f36aca to your computer and use it in GitHub Desktop.
Gets a bibtex file from a DOI or an ISBN
#!/bin/bash
str_utilisation="$0 (doi|isbn) <value>"
if [ "$#" -ne 2 ];then
echo ${str_utilisation}
exit 1
fi
if [ "$1" == "doi" ];then
doi_raw=$2
curl -G --data-urlencode "id=$doi_raw" "http://www.doi2bib.org/doi2bib"
elif [ "$1" == "isbn" ];then
isbn=$2
curl "http://www.ottobib.com/isbn/${isbn}/bibtex" | perl -l -0777 -ne 'print $1 if /<textarea.*?>\s*(.*?)\s*<\/textarea/si'
else
echo ${str_utilisation}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment