Created
September 12, 2021 07:39
-
-
Save Mr-Destructive/960e1f4d23d1ab09bb32e1b54a534054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read -p "Enter the coin name : " coin | |
read -p "Enter your national currency : " crncy | |
days=0 | |
#read -p "Enter the number of days past today: " days | |
touch temp.json price.txt | |
curl -o temp.json -X 'GET' \ | |
'https://api.coingecko.com/api/v3/coins/'$coin'/market_chart?vs_currency='$crncy'&days='$days'' \ | |
-H 'accept: application/json' &> /dev/null | |
grep -o -P '(?<=,).*(?=]],"m)' temp.json > price.txt | |
while read val | |
do | |
p=$val | |
done < price.txt | |
price=`printf "%.15f" $p` | |
echo "The value of $coin in $crncy is = $price" | |
rm temp.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment