Skip to content

Instantly share code, notes, and snippets.

@Mr-Destructive
Created September 12, 2021 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mr-Destructive/960e1f4d23d1ab09bb32e1b54a534054 to your computer and use it in GitHub Desktop.
Save Mr-Destructive/960e1f4d23d1ab09bb32e1b54a534054 to your computer and use it in GitHub Desktop.
#!/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