Skip to content
Snippets Groups Projects
Commit 081aa08b authored by rs11g21's avatar rs11g21
Browse files

Able to track all bitcoin stats

parent 33515563
No related branches found
No related tags found
No related merge requests found
#! /usr/bin/bash
#------------Date--------------------------
dateCollected=$(date +"%Y-%m-%d")
timeCollected=$(date +"%T")
dateTime="$dateCollected $timeCollected"
printf "Date Time : %s" "$dateTime"
#------------Bit Coin Price----------------
address=$(curl -s https://www.coindesk.com/price/bitcoin/)
bitCoinValue=$( echo $address | grep -o "<span class=\"currency-pricestyles__Price-sc-1rux8hj-0 eEpEzP\">.*<\/span>" 2> /dev/null | sed 's/\(<span class=\"currency-pricestyles__Price-sc-1rux8hj-0 eEpEzP\">\|<\/span>\)/\n/g' | head -n 2| sed 's/,//g')
printf "\nBitCoin Value : %s"$bitCoinValue;
#printf "\n"
#-------------Bit Coin 24H Low--------------
hour_24_low=$(echo $address | grep -o '<span class=\"typography__StyledTypography-owin6q-0 gqNskB\">[^<]*</span>' | sed 's/<span class=\"typography__StyledTypography-owin6q-0 gqNskB">\|<\/span>//g' | sed -E 's/\$|,|N\/A|M|B//g' | grep -v '^$' | head -n 1)
printf "\nBitCoin 24 Hour Low : %s"$hour_24_low;
#printf "\n"
#-------------Bit Coin 24H High-------------
hour_24_high=$(echo $address | grep -o '<span class=\"typography__StyledTypography-owin6q-0 gqNskB\">[^<]*</span>' | sed 's/<span class=\"typography__StyledTypography-owin6q-0 gqNskB">\|<\/span>//g' | sed -E 's/\$|,|N\/A|M|B//g' | grep -v '^$' | head -n 2 | tail -n 1)
printf "\nBitCoin 24 Hour High : %s"$hour_24_high;
#printf "\n"
#-------------Bit Coin 24H Open-------------
hour_24_open=$(echo $address | grep -o '<span class=\"typography__StyledTypography-owin6q-0 gqNskB\">[^<]*</span>' | sed 's/<span class=\"typography__StyledTypography-owin6q-0 gqNskB">\|<\/span>//g' | sed -E 's/\$|,|N\/A|M|B//g' | grep -v '^$' | head -n 3 | tail -n 1)
printf "\nBitCoin 24 Hour Open : %s"$hour_24_open;
#printf "\n"
#-------------Bit Coin Market Cap-------------
market_cap=$(echo $address | curl -s https://www.coindesk.com/price/bitcoin/ | grep -o '<span class=\"typography__StyledTypography-owin6q-0 gqNskB\">[^<]*</span>' | sed 's/<span class=\"typography__StyledTypography-owin6q-0 gqNskB">\|<\/span>//g' | sed -E 's/\$|,|N\/A|M|B//g' | grep -v '^$' | head -n 7 | tail -n 1)
printf "\nBitCoin Market Cap : %s"$market_cap;
#printf "\n"
#------------Bit Coin Change------------------
changesInValue=$(echo $address | grep -o '\(<span class=\"typography__StyledTypography-owin6q-0 gqNskB\">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\)[^<]*</span>' | sed 's/<span class=\"typography__StyledTypography-owin6q-0 gqNskB">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\|<\/span>//g'| sed -E 's/\$|,|N\/A|M|%|B//g' | grep -v '^$' | head -n 4 | tail -n 1);
printf "\nBitCoin Change In Value : %s"$changesInValue;
#printf "\n"
#------------Bit Coin Return------------------
returnPercentage=$(echo $address | grep -o '\(<span class=\"typography__StyledTypography-owin6q-0 gqNskB\">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\)[^<]*</span>' | sed 's/<span class=\"typography__StyledTypography-owin6q-0 gqNskB">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\|<\/span>//g'| sed -E 's/\$|,|N\/A|M|%|B//g' | grep -v '^$' | head -n 8 | tail -n 1);
printf "\nBitCoin Return Percentage : %s"$returnPercentage;
#printf "\n"
#----------- Bit Coin Volatility--------------
volatility=$(echo $address | grep -o '\(<span class=\"typography__StyledTypography-owin6q-0 gqNskB\">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\)[^<]*</span>' | sed 's/<span class=\"typography__StyledTypography-owin6q-0 gqNskB">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\|<\/span>//g'| sed -E 's/\$|,|N\/A|M|%|B//g' | grep -v '^$' | tail -n 3 | head -n 1);
printf "\nBitCoin Volatility : %s"$volatility;
#printf "\n"
#----------- Bit Coin 24 H Transanction Count--------------
transactionCount=$(echo $address | grep -o '\(<span class=\"typography__StyledTypography-owin6q-0 gqNskB\">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\)[^<]*</span>' | sed 's/<span class=\"typography__StyledTypography-owin6q-0 gqNskB">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\|<\/span>//g'| sed -E 's/\$|,|N\/A|M|%|B//g' | grep -v '^$' | tail -n 2 | head -n 1);
printf "\nBitCoin 24 H Transaction Count: %s"$transactionCount;
#printf "\n"
#----------- Bit Coin 24 H Average Transaction Fee --------------
transactionFee=$(echo $address | grep -o '\(<span class=\"typography__StyledTypography-owin6q-0 gqNskB\">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\)[^<]*</span>' | sed 's/<span class=\"typography__StyledTypography-owin6q-0 gqNskB">\|<span class=\"typography__StyledTypography-owin6q-0 jrTwew">\|<\/span>//g'| sed -E 's/\$|,|N\/A|M|%|B//g' | grep -v '^$' | tail -n 1);
printf "\nBitCoin Transaction Fee : %s"$transactionFee;
printf "\n"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment