dotfiles/home/.local/bin/scripts/bitcoin

13 lines
293 B
Plaintext
Raw Normal View History

2021-08-24 15:25:09 +00:00
#!/bin/sh
2021-10-22 11:19:06 +00:00
BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null || echo 'ERR')
2021-10-11 18:03:37 +00:00
if [ "$BTC_DATA" != "ERR" ]; then
BTC_PRICE=$(echo $BTC_DATA | jq -r ".bpi.USD.rate_float")
BTC_PRICE=$(printf "%.2f" "$BTC_PRICE")
echo \$"$BTC_PRICE"
else
echo "N/A"
fi
2021-08-24 15:25:09 +00:00