From 081aa08baaafedd803cd32928e7f669783c7598b Mon Sep 17 00:00:00 2001
From: rs11g21 <rs11g21@soton.ac.uk>
Date: Tue, 25 Apr 2023 04:09:33 +0800
Subject: [PATCH] Able to track all bitcoin stats

---
 bitCoinTracker.sh | 87 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100755 bitCoinTracker.sh

diff --git a/bitCoinTracker.sh b/bitCoinTracker.sh
new file mode 100755
index 0000000..bd81b57
--- /dev/null
+++ b/bitCoinTracker.sh
@@ -0,0 +1,87 @@
+#! /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"
+
+
+
+
+
+
+
+
+
-- 
GitLab