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.