Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bitcoin prices in real time from the coindesk website api (bash script)
#!/bin/bash
# Credit to David Walsh for the original script <https://davidwalsh.name/bitcoin>
# The improved version of David's script doesn't go back to prompt. It keeps refreshing the prices every 5 seconds.
# Prices are in USD, EUR & GBP (in real time)
# curl must be installed in terminal
clear
echo "Coindesk BTC: "
echo " USD EUR GBP "
while [ 1 ]
do
curl -s http://api.coindesk.com/v1/bpi/currentprice.json | python -c "import json, sys; bitcoin=json.load(sys.stdin); print bitcoin['bpi']['USD']['rate'] + '\t' + bitcoin['bpi']['EUR']['rate'] + '\t' + bitcoin['bpi']['GBP']['rate']"
printf "\033[A"
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment