5# Calculate number of entries
6readonly num_lines=$(wc -l < pairs.txt)
9# Fetch JSON for each currency pair
10cat pairs.txt | while read line; do
13 if [[ $line =~ ([0-9A-Z]+)[[:space:]]+([0-9A-Z]+)[[:space:]]+([A-Za-z]+) ]]; then
15 from=${BASH_REMATCH[1]}
17 exchange=${BASH_REMATCH[3]}
20 # Dump the JSON to tmp
21 json_filename=/tmp/tokens/$exchange-$from-$to-$period.json
22 echo "[$current_line/$num_lines] $from-$to @ $exchange written to $json_filename"
25 curl --silent "https://min-api.cryptocompare.com/data/histo$period?fsym=$from&tsym=$to&e=$exchange&api_key=$CCAPI&limit=2000" > $json_filename
29 current_line=$((current_line + 1))
34ls -l /tmp/tokens/*.json