From 8db63e04d9a35483681f4403623aa69fe9503398 Mon Sep 17 00:00:00 2001 From: parasmgautam18 Date: Sun, 12 Apr 2026 19:05:12 +0530 Subject: [PATCH] fixed crypto price script by fetching them from api --- scripts/crypto-price | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/crypto-price b/scripts/crypto-price index 2aa9a16..db3f5db 100644 --- a/scripts/crypto-price +++ b/scripts/crypto-price @@ -12,6 +12,10 @@ API_URL="https://api.binance.com/api/v3/ticker/price?symbol=${SYMBOL}" echo "Fetching price for $COIN..." +RESPONSE=$(curl -s "$API_URL") +PRICE=$(echo "$RESPONSE" | grep -oP '"price":"\K[^"]+') + +echo "Current price of $COIN is: $PRICE" # TODO: Use `curl -s` to fetch the JSON from $API_URL. # The JSON looks similar to: {"symbol":"BTCUSDT","price":"63000.00000000"} # Use `grep`, `sed`, `awk`, or `jq` (if installed) to extract just the exact price number.