#!/bin/bash #Goal: For each bibcode produce a file listing the authors # #usage: ./bc2authors input_file [starting_index] #input_file .. list of BibCodes of author #starting_index .. for first BibCode. Default is 1 #e.g. ./bc2authors ref_bc.dat # ./bc2authors cite_bc.dat 100 ADS_Token=$(cat ADS_Token) Auth="Authorization: Bearer:$ADS_Token" Query="https://api.adsabs.harvard.edu/v1/search/query?q=bibcode:" Output="&fl=author&rows=2000" if [[ -z $1 ]]; then echo "exit: need input BibCode file" exit -1 fi infile=$1 start=$2; i=${start:=1} while read BibCode do outfile=${infile%.*}"_"$(printf "%03d" $i)".dat" echo "#" $BibCode > $outfile echo $BibCode curl -s -H "$Auth" "$Query$BibCode$Output" | jq -r '.response.docs[0]|.author[]' >> $outfile i=$((i+1)) done < $infile