Trim trailing zeroes off a number extracted by jq
Pass the price through tonumber
:
curl -sS 'https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT' |
jq -r '.price | tonumber'
This would convert the price from a string to a number, removing the trailing zeros. See the manual for jq
.
If you don't mind using a Bash builtin, printf might be the way to go:
curl -sS https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT | jq -r '.price' | xargs printf '%.2f'
This way you will keep the two trailing digits and get a rounding done as well.
Awk is an option also
curl -sS https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT | jq -r '.price' | awk '{printf "%.2f\n", $1}'