#!/bin/bash if [ "$1" == "-h" ] ; then echo " urlconv - add blob to ipfs and convert corresponding referring url in a bibtex database file Usage: urlconv preprint.pdf references.bib " #echo "$(tput setaf 6)$EDITOR $(tput setaf 7)is currently set as editor" exit 0 fi fn=$1 bibFile=$2 relPath="ipfs://" hashid=$(ipfs add $fn | grep $fn | cut --delimiter=" " -f 2) sed -i -E "s|(\W*Url = \{).*$fn(\}.*)|\1$relPath$hashid\2|" $bibFile