$ cat cryptocurrency_price.sh
Result:
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 PAIR AMOUNT" >&2
exit 1
fi
pair=$1; amount=$2; curl -s "https://coincheck.com/api/rate/$pair" | python -c "import sys, json; print float(json.load(sys.stdin)['rate']) * float(sys.argv[1])" $amount
Command:
$ ./cryptocurrency_price.sh
Result:
Usage: ./cryptocurrency_price_jpy.sh PAIR AMOUNT
Command:
$ ./cryptocurrency_price.sh btc_jpy 1
Result:
318146.0
Command:
$ ./cryptocurrency_price_jpy.sh eth_jpy 13.5
Result:
303218.972773
Command:
$ ./cryptocurrency_price_jpy.sh xem_jpy 1000
Result:
18703.59758